fork download
  1. #include <cstdio>
  2. #include <queue>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int t;
  8. scanf("%d", &t);
  9. for(int zi=0; zi<t; zi++)
  10. {
  11. int n;
  12. int T[((int)1e6+7)];
  13. int oczekiwany=1;
  14. deque<int> torB;
  15. scanf("%d", &n);
  16. bool ok = true;
  17. for(int i= 0; i < n; i++)
  18. {
  19. int a;
  20. scanf("%d", &a);
  21.  
  22. if (a==oczekiwany) oczekiwany++;
  23. else
  24. {
  25. if (torB.empty() || a>torB.back()) torB.push_back(a);
  26. else ok=false;
  27. }
  28.  
  29. while(!torB.empty() && torB.front()==oczekiwany) {oczekiwany++; torB.pop_front();}
  30. }
  31. if (ok) printf("TAK\n"); else printf("NIE\n");
  32. }
  33. }
stdin
2 
3 
1 2 3 
3 
3 2 1
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:12: warning: unused variable ‘T’
prog.cpp:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
prog.cpp:15: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
prog.cpp:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
stdout
TAK
NIE