import java.util.Scanner; public class lus { public static void main(String[] args) { Scanner input = new Scanner(System.in); long n = input.nextLong(); for (long x = 0; x < n; x++) { boolean ok = true; long p = input.nextLong(); long a, b, c, d, a2, b2, c2, d2; a = input.nextLong(); b = input.nextLong(); c = input.nextLong(); d = input.nextLong(); for (long y = 1; y < p; y++) { a2 = input.nextLong(); b2 = input.nextLong(); c2 = input.nextLong(); d2 = input.nextLong(); if (a2 <= a && b2 >= b && c2 <= c && d2 >= d) { ok=true; a = a2; b = b2; c = c2; d = d2; continue; } else { if (a <= a2 && b >= b2 && c <= c2 && d >= d2 && ok) { ok=true; } else { a= a<a2?a:a2; b= b>b2?b:b2; c= c<c2?c:c2; d= d>d2?d:d2; ok = false; } } } if (ok) System.out.println("TAK"); else System.out.println("NIE"); } } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | import java.util.Scanner; public class lus { public static void main(String[] args) { Scanner input = new Scanner(System.in); long n = input.nextLong(); for (long x = 0; x < n; x++) { boolean ok = true; long p = input.nextLong(); long a, b, c, d, a2, b2, c2, d2; a = input.nextLong(); b = input.nextLong(); c = input.nextLong(); d = input.nextLong(); for (long y = 1; y < p; y++) { a2 = input.nextLong(); b2 = input.nextLong(); c2 = input.nextLong(); d2 = input.nextLong(); if (a2 <= a && b2 >= b && c2 <= c && d2 >= d) { ok=true; a = a2; b = b2; c = c2; d = d2; continue; } else { if (a <= a2 && b >= b2 && c <= c2 && d >= d2 && ok) { ok=true; } else { a= a<a2?a:a2; b= b>b2?b:b2; c= c<c2?c:c2; d= d>d2?d:d2; ok = false; } } } if (ok) System.out.println("TAK"); else System.out.println("NIE"); } } } |