import java.util.Scanner; public class lus { private static class A { int w_min, w_max, h_min, h_max; boolean ok; public void init(int w1, int w2, int h1, int h2) { w_min = w1; w_max = w2; h_min = h1; h_max = h2; ok = true; } public void update(int w1, int w2, int h1, int h2) { if (w1 < w_min) { w_min = w1; ok = false; } if (w2 > w_max) { w_max = w2; ok = false; } if (h1 < h_min) { h_min = h1; ok = false; } if (h2 > h_max) { h_max = h2; ok = false; } if (w_min==w1&&w_max==w2&&h_min==h1&&h_max==h2) { ok = true; } } public boolean test() { return ok; } } public static void main(String[] args) { A a = new A(); Scanner in = new Scanner(System.in); int t = in.nextInt(); while (t>0) { int n = in.nextInt(); n--; int w1 = in.nextInt(); int w2 = in.nextInt(); int h1 = in.nextInt(); int h2 = in.nextInt(); a.init(w1,w2,h1,h2); while (n>0) { w1 = in.nextInt(); w2 = in.nextInt(); h1 = in.nextInt(); h2 = in.nextInt(); a.update(w1,w2,h1,h2); n--; } System.out.println(a.test()?"TAK":"NIE"); t--; } } }
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | import java.util.Scanner; public class lus { private static class A { int w_min, w_max, h_min, h_max; boolean ok; public void init(int w1, int w2, int h1, int h2) { w_min = w1; w_max = w2; h_min = h1; h_max = h2; ok = true; } public void update(int w1, int w2, int h1, int h2) { if (w1 < w_min) { w_min = w1; ok = false; } if (w2 > w_max) { w_max = w2; ok = false; } if (h1 < h_min) { h_min = h1; ok = false; } if (h2 > h_max) { h_max = h2; ok = false; } if (w_min==w1&&w_max==w2&&h_min==h1&&h_max==h2) { ok = true; } } public boolean test() { return ok; } } public static void main(String[] args) { A a = new A(); Scanner in = new Scanner(System.in); int t = in.nextInt(); while (t>0) { int n = in.nextInt(); n--; int w1 = in.nextInt(); int w2 = in.nextInt(); int h1 = in.nextInt(); int h2 = in.nextInt(); a.init(w1,w2,h1,h2); while (n>0) { w1 = in.nextInt(); w2 = in.nextInt(); h1 = in.nextInt(); h2 = in.nextInt(); a.update(w1,w2,h1,h2); n--; } System.out.println(a.test()?"TAK":"NIE"); t--; } } } |