fork download
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. stack <string> sk;
  6. int main() {
  7. ios::sync_with_stdio(false);
  8. cin.tie(nullptr);
  9. //freopen(stdin);
  10.  
  11. int n;
  12. cin>>n;
  13. int start=n;
  14. if(n%2!=0)
  15. {
  16. cout<<"WA\n";
  17. }
  18.  
  19. else
  20. {
  21. bool flag=true;
  22. int countHeader=0;
  23. while(n--)
  24. {
  25. string s;
  26. cin>>s;
  27.  
  28.  
  29. if(s.substr(0,3)!="End")
  30. {
  31. sk.push(s);
  32. if(s=="Header")
  33. {
  34. countHeader++;
  35. }
  36.  
  37. }
  38. else
  39. {
  40. if(!sk.empty() &&s.substr(3)==sk.top())
  41. {
  42. sk.pop();
  43. }
  44. else
  45. {
  46. flag=false;
  47. break;
  48. }
  49. }
  50. }
  51.  
  52. if(sk.size()!=0|| !flag|| countHeader!=1 )
  53. {
  54. cout<<"WA\n";
  55. }
  56. else
  57. {
  58. cout<<"ACC\n";
  59. }
  60. }
  61.  
  62. return 0;
  63. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
WA