fork(1) download
  1. #include <cstdio>
  2.  
  3. int main() {
  4. int t, n, x[50009], y[50009], i;
  5. long long dx, dy, dx2, dy2;
  6. scanf("%d", &t);
  7.  
  8. while (t--) {
  9. scanf("%d", &n);
  10. for (i = 0; i < n; i++) {
  11. scanf("%d", &x[i]);
  12. scanf("%d", &y[i]);
  13. }
  14. if (n <= 2)
  15. printf("TAK\n");
  16. else {
  17. dx = x[1]-x[0];
  18. dy = y[1]-y[0];
  19. for (i = 2; i < n; i++) {
  20. dx2 = x[i]-x[0];
  21. dy2 = y[i]-y[0];
  22. if (dx == 0 && dy == 0) {
  23. dx = dx2;
  24. dy = dy2;
  25. }
  26. else if (dx == 0 || dx2 == 0) {
  27. if (dx != dx2)
  28. break;
  29. }
  30. else if (dx*dy2 != dy*dx2) // dy/dx == dy2/dx2
  31. break;
  32. }
  33. if (i == n)
  34. printf("TAK\n");
  35. else
  36. printf("NIE\n");
  37. }
  38. }
  39. }
  40.  
Success #stdin #stdout 0s 15504KB
stdin
6

5
0 0
0 1
0 0
0 0
1 0

4
0 0 
2 2
11 11
-2 -2

3
1 0
0 0 
0 1

4
1 1
1 1
2 2
2 2

5
1 1
1 1
2 2
2 2
1 2

5
1 1
1 1
2 2
2 2
3 3
stdout
NIE
TAK
NIE
TAK
NIE
TAK