-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_D_j_Vu.cpp
More file actions
46 lines (46 loc) · 889 Bytes
/
A_D_j_Vu.cpp
File metadata and controls
46 lines (46 loc) · 889 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
43
44
45
46
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(string s)
{
int l = 0;
int r = s.length() - 1;
while (l <= r)
{
if (s[l] != s[r])
{
string ans = s.substr(0, l + 1) + 'a' + s.substr(l + 1);
cout << "YES" << endl;
cout << ans << endl;
return;
}
else if (s[l] == s[r] && s[l] != 'a')
{
string ans = s.substr(0, l) + 'a' + s.substr(l);
cout << "YES" << endl;
cout << ans << endl;
return;
}
else
{
l++;
r--;
}
}
cout << "NO" << endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t;
cin >> t;
while (t--)
{
string s;
cin >> s;
solve(s);
}
return 0;
}