import java.io.*;
import static java.lang.Integer.*;
public class lus {
static class WS {
final int w1, w2, h1, h2;
WS(int w1, int w2, int h1, int h2) { this.w1 = w1; this.w2 = w2; this.h1 = h1; this.h2 = h2; }
boolean contains(WS it) {
return w1 <= it.w1 && w2 >= it.w2 && h1 <= it.h1 && h2 >= it.h2;
}
WS merge(WS it) {
return new WS(min(w1, it.w1), max(w2, it.w2), min(h1, it.h1), max(h2, it.h2));
}
}
private static final InputStream in = new BufferedInputStream(System.in);
private static int readInt() {
try {
int ret = 0, b;
while ((b = in.read()) != -1) if (b != ' ' && b != '\r' && b != '\n') break;
do if (b < '0' || b > '9') break;
else ret = ret * 10 + (b - '0'); while ((b = in.read()) != -1);
return ret;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static void main(String... args) {
int t = readInt();
for (int i = 0; i < t; ++i) {
int n = readInt();
WS m = null, w = new WS(MAX_VALUE, MIN_VALUE, MAX_VALUE, MIN_VALUE);
for (int j = 0; j < n; ++j) {
WS it = new WS(readInt(), readInt(), readInt(), readInt());
if (it.contains(w)) m = w;
else if (w.contains(it)) continue;
else m = null;
w = w.merge(it);
}
System.out.println(m != null ? "TAK" : "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.io.*; import static java.lang.Integer.*; public class lus { static class WS { final int w1, w2, h1, h2; WS(int w1, int w2, int h1, int h2) { this.w1 = w1; this.w2 = w2; this.h1 = h1; this.h2 = h2; } boolean contains(WS it) { return w1 <= it.w1 && w2 >= it.w2 && h1 <= it.h1 && h2 >= it.h2; } WS merge(WS it) { return new WS(min(w1, it.w1), max(w2, it.w2), min(h1, it.h1), max(h2, it.h2)); } } private static final InputStream in = new BufferedInputStream(System.in); private static int readInt() { try { int ret = 0, b; while ((b = in.read()) != -1) if (b != ' ' && b != '\r' && b != '\n') break; do if (b < '0' || b > '9') break; else ret = ret * 10 + (b - '0'); while ((b = in.read()) != -1); return ret; } catch (IOException e) { throw new RuntimeException(e); } } public static void main(String... args) { int t = readInt(); for (int i = 0; i < t; ++i) { int n = readInt(); WS m = null, w = new WS(MAX_VALUE, MIN_VALUE, MAX_VALUE, MIN_VALUE); for (int j = 0; j < n; ++j) { WS it = new WS(readInt(), readInt(), readInt(), readInt()); if (it.contains(w)) m = w; else if (w.contains(it)) continue; else m = null; w = w.merge(it); } System.out.println(m != null ? "TAK" : "NIE"); } } } |
English