fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int MAXA = 1000000000;
  5.  
  6. vector<int> A;
  7. vector<bool> L, R;
  8.  
  9. int main()
  10. {
  11. int n;
  12. cin >> n;
  13. A.resize(n + 2);
  14. A[0] = 0;
  15. for (int i = 1; i <= n; ++i) {
  16. cin >> A[i];
  17. }
  18. A[n + 1] = MAXA + 1;
  19. L.resize(n + 2);
  20. L[0] = true;
  21. for (int i = 1; i <= n + 1; ++i) {
  22. L[i] = L[i - 1] && (A[i - 1] < A[i]);
  23. }
  24. R.resize(n + 2);
  25. R[n + 1] = true;
  26. for (int i = n; i >= 0; --i) {
  27. R[i] = R[i + 1] && (A[i] < A[i + 1]);
  28. }
  29. for (int i = 1; i <= n; ++i) {
  30. if (!L[i - 1] || !R[i + 1]) {
  31. continue;
  32. }
  33. for (int a = A[i - 1] + 1; a < A[i + 1]; ++a) {
  34. if (a != A[i]) {
  35. cout << "TAK " << i << " " << a << endl;
  36. return 0;
  37. }
  38. }
  39. }
  40. cout << "NIE" << endl;
  41. return 0;
  42. }
Success #stdin #stdout 0s 15240KB
stdin
5
1 2 5 6 7
stdout
TAK 2 3