fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <stack>
  4.  
  5. int main(){
  6. std::stack<int> balls;
  7. int n, current_ball, extracted_ball;
  8. bool stop;
  9.  
  10. std::cin >> n;
  11.  
  12. current_ball = 1;
  13. while(n){
  14. std::cin >> extracted_ball;
  15. if(balls.empty()){
  16. balls.push(current_ball);
  17. current_ball++;
  18. }
  19. while(current_ball < n && balls.top() != extracted_ball){
  20. balls.push(current_ball);
  21. current_ball++;
  22. }
  23. if(balls.top() == extracted_ball) balls.pop();
  24. n--; //Условие остановки - просмотрели всю последовательность
  25. }
  26. if(balls.empty())
  27. std::cout << "Not a proof" << std::endl;
  28. else
  29. std::cout << "Cheater" << std::endl;
  30.  
  31. int pause;
  32. std::cin >> pause;
  33. }
Success #stdin #stdout 0s 3464KB
stdin
3 3 1 2
stdout
Cheater