fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7.  
  8. int x;
  9. cin >> x;
  10. deque<string> d(x);
  11. for (int i = 0; i < x; i++) {
  12. cin >> d[i];
  13. }
  14.  
  15. bool f = 1;
  16.  
  17.  
  18. if (d.front() != "Header" || d.back() != "EndHeader") {
  19. f = 0;
  20. }
  21.  
  22. else {
  23. d.pop_front();d.pop_back();
  24. while(!d.empty()) {
  25. string s="End"+d.front();
  26. if(d.front()=="Header")
  27. {
  28. f = 0;
  29. break;
  30. }
  31. cout<<s<<endl<<d.front()<<endl;
  32. if (d.empty()||s != d.back()) {
  33. f = 0;
  34. break;
  35. }
  36. d.pop_front();
  37. d.pop_back();
  38. }
  39. }
  40.  
  41. if (f)
  42. cout << "ACC";
  43. else
  44. cout << "WA";
  45.  
  46. return 0;
  47. }
Success #stdin #stdout 0s 5320KB
stdin
6
Header
Cell
EndCell
Row
EndRow
EndHeader
stdout
EndCell
Cell
WA