fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve() {
  5. string s; cin >> s;
  6. if (s.length() > 0) {
  7. for (int i = 1; i < s.length(); i++) {
  8. if (s[0] != s[i]) {
  9. string out = s;
  10. out[0] = s[i];
  11. out[i] = s[0];
  12. cout << "YES\n" << out << "\n";
  13. return;
  14. }
  15. }
  16. }
  17. cout << "NO\n";
  18. }
  19.  
  20. int main() {
  21. int t; cin >> t; for (int i = 0; i < t; i++) {solve();}
  22. }
Success #stdin #stdout 0.01s 5284KB
stdin
8
codeforces
aaaaa
xxxxy
co
d
nutdealer
mwistht
hhhhhhhhhh
stdout
YES
ocdeforces
NO
YES
yxxxx
YES
oc
NO
YES
untdealer
YES
wmistht
NO