fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t;
  6. cin >> t;
  7. while(t--)
  8. {
  9. string s;
  10. cin >> s;
  11. int n = s.length();
  12. for(int i=0;i<n;i++)
  13. {
  14. if((s[i]=='F')&&(s[i+1]=='F')&&(s[i+2]=='T'))
  15. {
  16. s[i+1] = 'T';
  17. s[i+2] = 'F';
  18. }
  19. else if((s[i]=='N')&&(s[i+1]=='T')&&(s[i+2]=='T'))
  20. {
  21. s[i]='T';
  22. s[i+1]='N';
  23. }
  24. }
  25. cout << s << endl;
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0.01s 5316KB
stdin
5
FFT
ABFBANTTA
FFTNTT
FFTFFTFFTNNTNNT
AFFTBFFNTTFTTZ
stdout
FTF
ABFBATNTA
FTFTNT
FTFFTFFTFNNTNNT
AFTFBFFTNTFTTZ