fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <cmath>
  5. #include <climits>
  6. #include <iomanip>
  7. #include <vector>
  8. #include <stack>
  9. #include <queue>
  10.  
  11. using namespace std;
  12. // P.Moriarty //
  13. #define AAD ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
  14. long long fac(int n)
  15. {
  16. long long fact = 1;
  17. for (int i = 1;i <= n;i++)
  18. {
  19. fact *= i;
  20. }
  21. return fact;
  22. }
  23. long long per(int n, int j)
  24. {
  25. long long p = 1;
  26. for (int i = n; i > n - j; i--)
  27. {
  28. p *= i;
  29. }
  30. return p;
  31. }
  32. bool lucky(int ch)
  33. {
  34. bool l = true;
  35.  
  36. while (ch > 0)
  37. {
  38. int d = ch % 10;
  39. if (d == 7 || d == 4)
  40. {
  41. ch /= 10;
  42. }
  43. else
  44. {
  45. l = false;
  46. break;
  47. }
  48. }
  49.  
  50. return l;
  51.  
  52. }
  53. int pro(int x, int i)
  54. {
  55. int r = 1;
  56. for (int j = 1;j <= i;j++)
  57. {
  58. r *= x;
  59. }
  60. return r;
  61. }
  62.  
  63. bool prime(int x) {
  64. if (x <= 1) return false;
  65. if (x == 2 || x == 3) return true;
  66. if (x % 2 == 0 || x % 3 == 0) return false;
  67.  
  68. for (int i = 5; i <= sqrt(x); i += 6) {
  69. if (x % i == 0 || x % (i + 2) == 0) return false;
  70. }
  71.  
  72. return true;
  73. }
  74.  
  75. int f(string a, string b)
  76. {
  77. int c = 0;
  78. for (int i = 0;i < a.size();i++)
  79. {
  80. if (a[i] == b[i])
  81. c++;
  82. }
  83. return c;
  84. }
  85.  
  86. int main()
  87. {
  88. AAD;
  89. vector<string>q;
  90. int n;
  91. cin >> n;
  92. bool ch = true;
  93. for(int i=0;i<n;i++)
  94. {
  95. string x;
  96. cin >> x;
  97. if (i == 0)
  98. q.push_back(x);
  99. else
  100. {
  101. string a = q[q.size() - 1];
  102. if (x[0] == 'E' && a[0] == x[3])
  103. {
  104. q.pop_back();
  105. }
  106. else
  107. {
  108. if (x[0] == 'E' && a[0] != x[3])
  109. {
  110. ch = false;
  111. break;
  112. }
  113. else
  114. q.push_back(x);
  115.  
  116. }
  117.  
  118. }
  119.  
  120. }
  121. if (q.size() == 0&&ch==true)
  122. cout << "ACC";
  123. else
  124. cout << "WA";
  125.  
  126.  
  127. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
WA