import java.io.BufferedReader; import java.io.InputStreamReader; public class lus { /** * @param args */ public static void main(String[] args) { try { final BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); // final BufferedReader bf = new BufferedReader(new FileReader(new File("C:\\Users\\Szafa\\prog\\Potyczki2014\\lus\\dane_testowe_max"))); int t = Integer.parseInt(bf.readLine()); for (int i = 0; i < t; i++) { boolean result = false; int n = Integer.parseInt(bf.readLine()); int minW = Integer.MAX_VALUE, maxW = 0, minH = Integer.MAX_VALUE, maxH = 0; for (int j = 0; j < n; j++) { String[] line = bf.readLine().split(" "); int w1 = Integer.parseInt(line[0]); int w2 = Integer.parseInt(line[1]); int h1 = Integer.parseInt(line[2]); int h2 = Integer.parseInt(line[3]); int tmp = 0; if (w1 <= minW) { tmp++; } if (w2 >= maxW) { tmp++; } if (h1 <= minH) { tmp++; } if (h2 >= maxH) { tmp++; } if (tmp == 4) { result = true; minW = w1; maxW = w2; minH = h1; maxH = h2; } else { tmp = 0; if (w1 < minW) { minW = w1; tmp++; } if (w2 > maxW) { maxW = w2; tmp++; } if (h1 < minH) { minH = h1; tmp++; } if (h2 > maxH) { maxH = h2; tmp++; } if (tmp > 0) { result = false; } } } if (result) { System.out.println("TAK"); } else { System.out.println("NIE"); } } bf.close(); } catch (Throwable e) { e.printStackTrace(); } } }
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 | import java.io.BufferedReader; import java.io.InputStreamReader; public class lus { /** * @param args */ public static void main(String[] args) { try { final BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); // final BufferedReader bf = new BufferedReader(new FileReader(new File("C:\\Users\\Szafa\\prog\\Potyczki2014\\lus\\dane_testowe_max"))); int t = Integer.parseInt(bf.readLine()); for (int i = 0; i < t; i++) { boolean result = false; int n = Integer.parseInt(bf.readLine()); int minW = Integer.MAX_VALUE, maxW = 0, minH = Integer.MAX_VALUE, maxH = 0; for (int j = 0; j < n; j++) { String[] line = bf.readLine().split(" "); int w1 = Integer.parseInt(line[0]); int w2 = Integer.parseInt(line[1]); int h1 = Integer.parseInt(line[2]); int h2 = Integer.parseInt(line[3]); int tmp = 0; if (w1 <= minW) { tmp++; } if (w2 >= maxW) { tmp++; } if (h1 <= minH) { tmp++; } if (h2 >= maxH) { tmp++; } if (tmp == 4) { result = true; minW = w1; maxW = w2; minH = h1; maxH = h2; } else { tmp = 0; if (w1 < minW) { minW = w1; tmp++; } if (w2 > maxW) { maxW = w2; tmp++; } if (h1 < minH) { minH = h1; tmp++; } if (h2 > maxH) { maxH = h2; tmp++; } if (tmp > 0) { result = false; } } } if (result) { System.out.println("TAK"); } else { System.out.println("NIE"); } } bf.close(); } catch (Throwable e) { e.printStackTrace(); } } } |