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.  
  34. for (int i = 0; i < n; i++)
  35. {
  36.  
  37. string start;
  38. cin >> start;
  39. if (start == "Header" && i == 0)
  40. cnt--;
  41. if (cnt < 0)
  42. acc = 0;
  43. if (start == "EndHeader" && i != n - 1)
  44. acc = 0;
  45.  
  46. if (start[0] == 'E' and start[1] == 'n' and start[2] == 'd' and i == 0)
  47. {
  48. acc = 0;
  49. }
  50. else if (start[0] != 'E' and start[1] != 'n' and start[2] != 'd')
  51. {
  52. st.emplace(start);
  53. }
  54. else
  55. {
  56. string s = st.top();
  57. if (s[0] == start[3])
  58. st.pop();
  59. else
  60. acc = 0;
  61. }
  62. }
  63. if (acc and st.empty() == true)
  64. cout << "ACC" << endl;
  65. else
  66. cout << "WA" << endl;
  67. }
  68. }
  69. return 0;
  70. }
Success #stdin #stdout 0.01s 5432KB
stdin
Standard input is empty
stdout
WA