fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. #define NeedForSpeed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
  5. #define int long long
  6. #define endl '\n'
  7. #define all(x) (x).begin(), (x).end()
  8. #define Create_File freopen("code.in", "r", stdin);
  9. const long long INF = 1ll << 32;
  10. const long double PI = acos(-1);
  11. const int N = 200005, mod = 1000000007;
  12.  
  13. int32_t main()
  14. {
  15. NeedForSpeed;
  16. // Create_File;
  17.  
  18. int test_cases = 1;
  19. // cin >> test_cases;
  20. int cases = 1;
  21. while (test_cases--)
  22. {
  23. int n;
  24. cin >> n;
  25. if (n % 2 == 1)
  26. cout << "WA" << endl;
  27. else
  28. {
  29.  
  30. stack<string> st;
  31. bool acc = true;
  32. int cnt = 1;
  33. for (int i = 0; i < n; i++)
  34. {
  35.  
  36. string start;
  37. cin >> start;
  38. if (start == "EndHeader" && st.top() != "Header" && st.empty() != 1)
  39. {
  40. acc = 0;
  41. }
  42. if (start[0] == 'E' and start[1] == 'n' and start[2] == 'd' and i == 0)
  43. {
  44. acc = 0;
  45. }
  46. else if (start[0] != 'E' and start[1] != 'n' and start[2] != 'd')
  47. {
  48. st.emplace(start);
  49. }
  50. else
  51. {
  52. string s = st.top();
  53. bool optimal = true;
  54. for (int i = 0; i < s.size(); i++)
  55. {
  56. if (s[i] == start[i + 3])
  57. optimal = true;
  58. else
  59. {
  60. acc = 0;
  61. break;
  62. optimal = 0;
  63. }
  64. }
  65. if (optimal)
  66. st.pop();
  67. else
  68. acc = 0;
  69. }
  70. }
  71. if (acc and st.empty() == true)
  72. cout << "ACC" << endl;
  73. else
  74. cout << "WA" << endl;
  75. }
  76. }
  77. return 0;
  78. }
Success #stdin #stdout 0.01s 5432KB
stdin
Standard input is empty
stdout
WA