import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * @author khelman */ public class lus { public static void main(String... args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String s = reader.readLine(); int t = Integer.parseInt(s); for (int i = 0; i < t; i++) { s = reader.readLine(); int n = Integer.parseInt(s); int min_w1 = 1000000000; int max_w2 = -1; int min_h1 = 1000000000; int max_h2 = -1; int w1_i = -1; int w2_i = -1; int h1_i = -1; int h2_i = -1; for (int j = 0; j < n; j++) { s = reader.readLine(); String[] elems = s.split(" "); int w1 = Integer.parseInt(elems[0]); int w2 = Integer.parseInt(elems[1]); int h1 = Integer.parseInt(elems[2]); int h2 = Integer.parseInt(elems[3]); if (w1 < min_w1) { min_w1 = w1; w1_i = j; if(w2==max_w2) {w2_i = j;} if(h1==min_h1) {h1_i = j;} if(h2==max_h2) {h2_i = j;} } if (w2 > max_w2) { max_w2 = w2; w2_i = j; if(w1==min_w1) {w1_i = j;} if(h1==min_h1) {h1_i = j;} if(h2==max_h2) {h2_i = j;} } if (h1 < min_h1) { min_h1 = h1; h1_i = j; if(w1==min_w1) {w1_i = j;} if(w2==max_w2) {w2_i = j;} if(h2==max_h2) {h2_i = j;} } if (h2 > max_h2) { max_h2 = h2; h2_i = j; if(w1==min_w1) {w1_i = j;} if(w2==max_w2) {w2_i = j;} if(h1==min_h1) {h1_i = j;} } } if (w1_i == w2_i && w1_i == h1_i && w1_i == h2_i) { 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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * @author khelman */ public class lus { public static void main(String... args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String s = reader.readLine(); int t = Integer.parseInt(s); for (int i = 0; i < t; i++) { s = reader.readLine(); int n = Integer.parseInt(s); int min_w1 = 1000000000; int max_w2 = -1; int min_h1 = 1000000000; int max_h2 = -1; int w1_i = -1; int w2_i = -1; int h1_i = -1; int h2_i = -1; for (int j = 0; j < n; j++) { s = reader.readLine(); String[] elems = s.split(" "); int w1 = Integer.parseInt(elems[0]); int w2 = Integer.parseInt(elems[1]); int h1 = Integer.parseInt(elems[2]); int h2 = Integer.parseInt(elems[3]); if (w1 < min_w1) { min_w1 = w1; w1_i = j; if(w2==max_w2) {w2_i = j;} if(h1==min_h1) {h1_i = j;} if(h2==max_h2) {h2_i = j;} } if (w2 > max_w2) { max_w2 = w2; w2_i = j; if(w1==min_w1) {w1_i = j;} if(h1==min_h1) {h1_i = j;} if(h2==max_h2) {h2_i = j;} } if (h1 < min_h1) { min_h1 = h1; h1_i = j; if(w1==min_w1) {w1_i = j;} if(w2==max_w2) {w2_i = j;} if(h2==max_h2) {h2_i = j;} } if (h2 > max_h2) { max_h2 = h2; h2_i = j; if(w1==min_w1) {w1_i = j;} if(w2==max_w2) {w2_i = j;} if(h1==min_h1) {h1_i = j;} } } if (w1_i == w2_i && w1_i == h1_i && w1_i == h2_i) { System.out.println("TAK"); } else { System.out.println("NIE"); } } } } |