fork download
  1. /**
  2.  * @brief : GNU C++11 application
  3.  * @details : Works stably on GNU C++11 (g++ 4.9.2, flag -std=c++11)
  4.  *
  5.  * @author : SergeiEgorov
  6.  * @date : July 10, 2015
  7.  */
  8.  
  9. #include <bits/stdc++.h>
  10.  
  11. using namespace std;
  12. using namespace __gnu_cxx;
  13.  
  14. #define file "file"
  15.  
  16. constexpr char el = '\n';
  17. constexpr int inf = (int) 1e9 + 7;
  18. constexpr long long l_inf = (long long) 4e18 + 13ll;
  19. constexpr long double eps = 1e-9;
  20. constexpr long long mod = (1ll << 62);
  21.  
  22. string s;
  23.  
  24. inline string solve()
  25. {
  26. for (int i = s.size() - 1; i >= 0; )
  27. {
  28. if (i >= 5 && s.substr(i - 5, 6) == "output")
  29. {
  30. i -= 6;
  31. continue;
  32. }
  33.  
  34. if (i >= 4 && (s.substr(i - 4, 5) == "input" || s.substr(i - 4, 5) == "puton"))
  35. {
  36. i -= 5;
  37. continue;
  38. }
  39.  
  40. if (i >= 2 && (s.substr(i - 2, 3) == "one" || s.substr(i - 2, 3) == "out"))
  41. {
  42. i -= 3;
  43. continue;
  44. }
  45.  
  46. if (i >= 1 && s.substr(i - 1, 2) == "in")
  47. {
  48. i -= 2;
  49. continue;
  50. }
  51.  
  52. return string("NO");
  53. }
  54.  
  55. return string("YES");
  56. }
  57.  
  58. int main()
  59. {
  60. ios_base::sync_with_stdio(false);
  61. cin.tie(nullptr);
  62. srand(time(nullptr));
  63.  
  64. #ifdef HOME
  65. freopen(file".in", "r", stdin);
  66. freopen(file".out", "w", stdout);
  67. #endif
  68.  
  69. int T;
  70. cin >> T;
  71.  
  72. while (T--)
  73. {
  74. cin >> s;
  75. cout << solve() << el;
  76. }
  77.  
  78. return 0;
  79. }
Success #stdin #stdout 0s 3280KB
stdin
6
ab
ad
one
outout
output
outone
stdout
NO
NO
YES
YES
YES
YES