-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1971B.cpp
More file actions
42 lines (36 loc) · 850 Bytes
/
Copy path1971B.cpp
File metadata and controls
42 lines (36 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Created on 10-May-24
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
int main() {
int t;
cin >> t;
while (t--) {
string s, tempS;
cin >> s;
tempS = s;
char s2 = s[0];
int count = 0, index = -1;
for (int i = 0; i < s.size(); i++) {
if (s[i] == s2) count++;
else {
index = i;
break;
}
}
if (count == s.size()) cout << "NO" << endl;
else {
sort(s.begin(), s.end());
if (s != tempS) {
cout << "YES" << endl << s << endl;
} else {
sort(s.rbegin(), s.rend());
cout << "YES" << endl << s << endl;
}
}
}
return 0;
}