fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. ll n;
  8. cin>>n;
  9. stack<string>st ;
  10. bool w=0;
  11. ll cnt=0;
  12. for(int i=0;i<n;i++){
  13. string x;cin>>x;
  14. if(i==0&&x=="EndHeader"){
  15. w=1;
  16. break;
  17. }
  18. if(x=="Header")cnt++;
  19. if(i==0&&x!="Header"){
  20. w=1;
  21. break;
  22. }
  23. if(x[0]!='E'&&x[1]!='n'&&x[2]!='d')st.push(x);
  24. else {
  25. string s=st.top();
  26. st.pop();
  27. string t="End"+s;
  28. // cout<<t<<"\n";
  29. if(t!=x){
  30. w=1;
  31. break;
  32. }
  33. }
  34. }
  35. // cout<<st.size()<<"\n";
  36. if(w||st.size()>=1||cnt>1)cout<<"WA\n";
  37. else cout<<"ACC\n";
  38. return 0;
  39. }
Success #stdin #stdout 0.01s 5264KB
stdin
Standard input is empty
stdout
WA