-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1971B_Different_String.cpp
More file actions
51 lines (47 loc) · 1.08 KB
/
Copy path1971B_Different_String.cpp
File metadata and controls
51 lines (47 loc) · 1.08 KB
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
43
44
45
46
47
48
49
50
51
// https://codeforces.com/contest/1971/problem/B
// @handle: imransihab0
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define py cout << "YES" << endl
#define pn cout << "NO" << endl
#define FastIO() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int32_t main(){
FastIO();
int t;
cin >> t;
while(t--)
{
string s, _s;
cin >> s;
_s = s;
set<char> se;
for(auto i:s)
{
se.insert(i);
}
if(se.size() == 1) pn;
else
{
py;
reverse(_s.begin(), _s.end());
if(s == _s)
{
for(int i=0; i<_s.size()-1; i++)
{
swap(_s[i], _s[i+1]);
if(s != _s)
{
cout << _s << endl;
break;
}
}
}
else
{
cout << _s << endl;
}
}
}
return 0;
}