import java.io.IOException; import java.io.InputStream; /** * * @author Marcin Lewandowski */ public class lus { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { int t = readInt(System.in); round: for (int round = 0; round < t; round++) { int n =readInt(System.in); int[][] sizes = new int[n][4]; int borderValues [] = new int[]{Integer.MAX_VALUE,0,Integer.MAX_VALUE,0}; for(int i =0; i< n; i++){ for(int j =0; j<4; j++){ sizes[i][j] = readInt(System.in); if((j%2==0 && borderValues[j] > sizes[i][j]) || (j%2!=0 && borderValues[j] < sizes[i][j])){ borderValues[j] = sizes[i][j]; } } } outer: for(int i =0; i< n; i++){ for(int j =0; j<4; j++){ if(sizes[i][j] != borderValues[j]){ continue outer; } } System.out.println("TAK"); continue round; } System.out.println("NIE"); } } private static int readInt(InputStream in) throws IOException { int result = 0; boolean isDigit = false; int c = 0; while((c = in.read()) != -1) { if (c >= '0' && c <= '9') { isDigit = true; result = result * 10 + c - '0'; } else if (isDigit) { break; } } return result; } }
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 | import java.io.IOException; import java.io.InputStream; /** * * @author Marcin Lewandowski */ public class lus { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { int t = readInt(System.in); round: for (int round = 0; round < t; round++) { int n =readInt(System.in); int[][] sizes = new int[n][4]; int borderValues [] = new int[]{Integer.MAX_VALUE,0,Integer.MAX_VALUE,0}; for(int i =0; i< n; i++){ for(int j =0; j<4; j++){ sizes[i][j] = readInt(System.in); if((j%2==0 && borderValues[j] > sizes[i][j]) || (j%2!=0 && borderValues[j] < sizes[i][j])){ borderValues[j] = sizes[i][j]; } } } outer: for(int i =0; i< n; i++){ for(int j =0; j<4; j++){ if(sizes[i][j] != borderValues[j]){ continue outer; } } System.out.println("TAK"); continue round; } System.out.println("NIE"); } } private static int readInt(InputStream in) throws IOException { int result = 0; boolean isDigit = false; int c = 0; while((c = in.read()) != -1) { if (c >= '0' && c <= '9') { isDigit = true; result = result * 10 + c - '0'; } else if (isDigit) { break; } } return result; } } |