import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
public class lus {
public static void main(String[] args) {
try (Scanner in = new Scanner(System.in)) {
int tests = in.nextInt();
while (tests-- > 0) {
int companies = in.nextInt();
List<Size> sizes = new LinkedList<Size>();
for (int i = 0; i < companies; i++) {
sizes.add(new Size(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt()));
}
boolean printed = false;
for (Size size : sizes) {
boolean dominant = true;
for (Size other : sizes) {
if (other.wMin < size.wMin || other.wMax > size.wMax || other.hMin < size.hMin || other.hMax > size.hMax) {
dominant = false;
break;
}
}
if (dominant == true) {
System.out.println("TAK");
printed = true;
break;
}
}
if (!printed) {
System.out.println("NIE");
}
}
}
}
private static class Size {
public final int wMin;
public final int wMax;
public final int hMin;
public final int hMax;
public Size(int wMin, int wMax, int hMin, int hMax) {
this.wMin = wMin;
this.wMax = wMax;
this.hMin = hMin;
this.hMax = hMax;
}
}
}
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 | import java.util.LinkedList; import java.util.List; import java.util.Scanner; public class lus { public static void main(String[] args) { try (Scanner in = new Scanner(System.in)) { int tests = in.nextInt(); while (tests-- > 0) { int companies = in.nextInt(); List<Size> sizes = new LinkedList<Size>(); for (int i = 0; i < companies; i++) { sizes.add(new Size(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt())); } boolean printed = false; for (Size size : sizes) { boolean dominant = true; for (Size other : sizes) { if (other.wMin < size.wMin || other.wMax > size.wMax || other.hMin < size.hMin || other.hMax > size.hMax) { dominant = false; break; } } if (dominant == true) { System.out.println("TAK"); printed = true; break; } } if (!printed) { System.out.println("NIE"); } } } } private static class Size { public final int wMin; public final int wMax; public final int hMin; public final int hMax; public Size(int wMin, int wMax, int hMin, int hMax) { this.wMin = wMin; this.wMax = wMax; this.hMin = hMin; this.hMax = hMax; } } } |
English