/** * @author Tadeusz Faber (SI-Consulting SA). * * Potyczki Algorytmiczne 2014. * * 2014-05-12 Runda 1B. Lustra. * * Pamiec: 128MB. * Czas: ?s. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; public final class lus { private static Reader in = null; /** * Zwroc kolejna liczbe calkowita ze strumienia in * * @return wczytana liczba */ private static int nextInteger() { int r = 0; boolean minus = false; char c; try { do { c = (char) in.read(); } while (c == ' ' || c == '\n' || c == '\r'); if (c == '-') { minus = true; c = (char) in.read(); } do { r = r * 10 + (int) c - 48; c = (char) in.read(); } while (c != ' ' && c != '\n' && c != '\r' && c != (char) -1); } catch (Exception ex) { ex.printStackTrace(); } if (minus) { return -r; } else { return r; } } /** * @param args */ public static void main(String[] args) throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); long t = nextInteger(); // 1..10 for (long ti = 1; ti <= t; ti++) { long n = nextInteger();// 2..100 000 long mw1 = Long.MAX_VALUE; long mw2 = Long.MIN_VALUE; long mh1 = Long.MAX_VALUE; long mh2 = Long.MIN_VALUE; boolean covered = false; for (long ni = 1; ni <= n; ni++) { long w1 = nextInteger(); // 1.. 1 000 000 000 long w2 = nextInteger(); // 1.. 1 000 000 000 long h1 = nextInteger(); // 1.. 1 000 000 000 long h2 = nextInteger(); // 1.. 1 000 000 000 if (mw1 > w1) { covered = false; mw1 = w1; } if (mw2 < w2) { covered = false; mw2 = w2; } if (mh1 > h1) { covered = false; mh1 = h1; } if (mh2 < h2) { covered = false; mh2 = h2; } if (!covered) { if (mw1 == w1 && mw2 == w2 && mh1 == h1 && mh2 == h2) { covered = true; } } } if (covered) { 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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | /** * @author Tadeusz Faber (SI-Consulting SA). * * Potyczki Algorytmiczne 2014. * * 2014-05-12 Runda 1B. Lustra. * * Pamiec: 128MB. * Czas: ?s. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; public final class lus { private static Reader in = null; /** * Zwroc kolejna liczbe calkowita ze strumienia in * * @return wczytana liczba */ private static int nextInteger() { int r = 0; boolean minus = false; char c; try { do { c = (char) in.read(); } while (c == ' ' || c == '\n' || c == '\r'); if (c == '-') { minus = true; c = (char) in.read(); } do { r = r * 10 + (int) c - 48; c = (char) in.read(); } while (c != ' ' && c != '\n' && c != '\r' && c != (char) -1); } catch (Exception ex) { ex.printStackTrace(); } if (minus) { return -r; } else { return r; } } /** * @param args */ public static void main(String[] args) throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); long t = nextInteger(); // 1..10 for (long ti = 1; ti <= t; ti++) { long n = nextInteger();// 2..100 000 long mw1 = Long.MAX_VALUE; long mw2 = Long.MIN_VALUE; long mh1 = Long.MAX_VALUE; long mh2 = Long.MIN_VALUE; boolean covered = false; for (long ni = 1; ni <= n; ni++) { long w1 = nextInteger(); // 1.. 1 000 000 000 long w2 = nextInteger(); // 1.. 1 000 000 000 long h1 = nextInteger(); // 1.. 1 000 000 000 long h2 = nextInteger(); // 1.. 1 000 000 000 if (mw1 > w1) { covered = false; mw1 = w1; } if (mw2 < w2) { covered = false; mw2 = w2; } if (mh1 > h1) { covered = false; mh1 = h1; } if (mh2 < h2) { covered = false; mh2 = h2; } if (!covered) { if (mw1 == w1 && mw2 == w2 && mh1 == h1 && mh2 == h2) { covered = true; } } } if (covered) { System.out.println("TAK"); } else { System.out.println("NIE"); } } } } |