fork download
  1. #include<iostream>
  2. #include<math.h>
  3. #include<iomanip>
  4. #include <string>
  5. #include<algorithm>
  6. #include <vector>
  7. #include<queue>
  8. #include<deque>
  9. #include<stack>
  10. #include<map>
  11. #define all(v) v.begin(), v.end()
  12. #define Gareth_Bale ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  13. typedef long long ll;
  14. typedef double ld;
  15. using namespace std;
  16.  
  17. int gcd(int a, int b) {
  18. while (b != 0) {
  19. int x = a;
  20. a = b;
  21. b = x % b;
  22. }
  23. return a;
  24. }
  25. int lcm(int a, int b) {
  26. return (a * b) / gcd(a, b);
  27. }
  28. long long rev_num(long long n) {
  29. long long rev = 0;
  30. while (n > 0)
  31. {
  32. int digit = n % 10;
  33. rev = rev * 10 + digit;
  34. n /= 10;
  35. }
  36. return rev;
  37. }
  38. bool isPrime(long long n) {
  39. if (n <= 1) return false;
  40. for (int i = 2; i * i <= n; i++)
  41. if (n % i == 0) return false;
  42. return true;
  43. }
  44. bool islucky(long long n) {
  45. while (n > 0) {
  46. int digit = n % 10;
  47. if (digit != 4 && digit != 7) {
  48. return false;
  49. }
  50. n /= 10;
  51. }
  52. return true;
  53. }
  54. bool preceed(ll x, ll y) {
  55. return x > y;
  56. }
  57.  
  58. int main() {
  59. Gareth_Bale;
  60. int q; cin >> q; stack<string>st;
  61. while (q--) {
  62. string s;cin >> s;
  63. if (s == "Header" || s == "Row" || s == "Cell" || s == "Table")
  64. st.push(s);
  65.  
  66. else if (!st.empty() && st.top() == "Header" && s == "EndHeader")
  67. st.pop();
  68.  
  69. else if (!st.empty() && st.top() == "Row" && s == "EndRow")
  70. st.pop();
  71.  
  72. else if (!st.empty() && st.top() == "Cell" && s == "EndCell")
  73. st.pop();
  74.  
  75. else if (!st.empty() && st.top() == "Table" && s == "EndTable")
  76. st.pop();
  77.  
  78. else
  79. {
  80. cout << "WA";
  81. return 0;
  82. }
  83. }
  84. cout << "ACC";
  85. return 0;
  86. }
  87.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
WA