fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Mod=1e9+7;
  5. const ll INF = 10000000000000;
  6. const int N = 1e6+7;
  7.  
  8. void solve() {
  9. string s;
  10. cin >> s;
  11. if(s[2]=='c') cout << "YES\n";
  12. else{
  13. for(int i=0;i<2;i++)
  14. if(s[i]=='c') swap(s[i],s[2]);
  15. if(s=="abc") cout << "YES\n";
  16. else cout << "NO\n";
  17. }
  18. }
  19.  
  20. int main(){
  21. ios::sync_with_stdio(false);
  22. cin.tie(nullptr);
  23.  
  24. int t;
  25. cin >> t;
  26. while (t--) solve();
  27.  
  28.  
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0s 5308KB
stdin
6
abc
acb
bac
bca
cab
cba
stdout
YES
YES
YES
NO
NO
YES