Codeforces Round 944 (Div. 4) B. Different String

Codeforces Round 944 (Div. 4)

B. Different String

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
// By SnowDream
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10;
string s;
char tmp;
bool flag;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while(t--)
{
cin >> s;
if(s.size()<=1)
{
cout << "NO\n";
continue;
}
flag=false;
for(int i=1;i<s.size();++i)
{
if(s[i]!=s[i-1])
{
tmp=s[i-1];
s[i-1]=s[i];
s[i]=tmp;
flag=true;
break;
}
}
if(flag)
{
cout << "YES\n" << s << "\n";
}
else
{
cout << "NO\n";
}
}
return 0;
}

Codeforces Round 944 (Div. 4) B. Different String
http://snowdreamxue.github.io/2024/10/21/Codeforces Round 944 (Div. 4)/B. Different String/
Author
SnowDream
Posted on
October 21, 2024
Licensed under