fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios_base::sync_with_stdio(0);
  6. cout.tie(0);
  7. cin.tie(0);
  8.  
  9. int t;
  10. cin >> t;
  11.  
  12. int n;
  13. while(t--)
  14. {
  15. cin >> n;
  16.  
  17. bool check = true;
  18. long long x1, y1, x2, y2, x, y;
  19. vector<long long> X, Y;
  20.  
  21. if(n <= 2)
  22. {
  23. for(int i = 1; i <= n; ++i)
  24. cin >> x >> y;
  25. cout << "TAK" << endl;
  26. continue;
  27. }
  28. cin >> x1 >> y1;
  29. cin >> x2 >> y2;
  30.  
  31. X.push_back(x1);
  32. X.push_back(x2);
  33. Y.push_back(y1);
  34. Y.push_back(y2);
  35.  
  36. if(x1 == x2 && y1 != y2)
  37. {
  38. for(int i = 3; i <= n; ++i)
  39. {
  40. cin >> x >> y;
  41. if(x != x1)
  42. {
  43. check = false;
  44. break;
  45. }
  46. }
  47. if(!check)
  48. cout << "NIE" << endl;
  49. else
  50. cout << "TAK" << endl;
  51. continue;
  52. }
  53.  
  54. for(int i = 3; i <= n; ++i)
  55. {
  56. cin >> x >> y;
  57. X.push_back(x);
  58. Y.push_back(y);
  59. }
  60.  
  61. long long a;
  62. for(int i = 2; i < n; ++i)
  63. {
  64. a = (Y[i-2]-Y[i-1])*(X[i-2]-X[i]) - (Y[i-2]-Y[i])*(X[i-2]-X[i-1]);
  65. if(a != 0)
  66. {
  67. check = false;
  68. break;
  69. }
  70. }
  71.  
  72. if(!check)
  73. cout << "NIE" << endl;
  74. else
  75. cout << "TAK" << endl;
  76. }
  77.  
  78. return 0;
  79. }
  80.  
Success #stdin #stdout 0s 5372KB
stdin
4
4
0 0 
2 2
11 11
-2 -2
3
1 0
0 0 
0 1
3
1 5
1 9
1 413
3
4 32
8 32
9 32
stdout
TAK
NIE
TAK
TAK