import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * Date: 12.05.2014 * Time: 18:57 * * @Author Kamil Sobol */ public class lus { public static void main(String[] args) throws Exception { final BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); final int samples = Integer.valueOf(input.readLine()); for (int i = 0; i < samples; i++) { boolean isMajor = true; final int suppliers = Integer.valueOf(input.readLine()); StringTokenizer stringTokenizer = new StringTokenizer(input.readLine()); int min_w = Integer.valueOf(stringTokenizer.nextToken()); int max_w = Integer.valueOf(stringTokenizer.nextToken()); int min_h = Integer.valueOf(stringTokenizer.nextToken()); int max_h = Integer.valueOf(stringTokenizer.nextToken()); for (int j = 1; j < suppliers; j++) { stringTokenizer = new StringTokenizer(input.readLine()); final int w1 = Integer.valueOf(stringTokenizer.nextToken()); final int w2 = Integer.valueOf(stringTokenizer.nextToken()); final int h1 = Integer.valueOf(stringTokenizer.nextToken()); final int h2 = Integer.valueOf(stringTokenizer.nextToken()); isMajor = ( w1 <= min_w && w2 >= max_w && h1 <= min_h && h2 >= max_h ) || ( isMajor && w1 >= min_w && w2 <= max_w && h1 >= min_h && h2 <= max_h ); min_w = Math.min(min_w, w1); max_w = Math.max(max_w, w2); min_h = Math.min(min_h, h1); max_h = Math.max(max_h, h2); } System.out.println(isMajor ? "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 50 51 52 53 54 55 56 57 58 | import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * Date: 12.05.2014 * Time: 18:57 * * @Author Kamil Sobol */ public class lus { public static void main(String[] args) throws Exception { final BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); final int samples = Integer.valueOf(input.readLine()); for (int i = 0; i < samples; i++) { boolean isMajor = true; final int suppliers = Integer.valueOf(input.readLine()); StringTokenizer stringTokenizer = new StringTokenizer(input.readLine()); int min_w = Integer.valueOf(stringTokenizer.nextToken()); int max_w = Integer.valueOf(stringTokenizer.nextToken()); int min_h = Integer.valueOf(stringTokenizer.nextToken()); int max_h = Integer.valueOf(stringTokenizer.nextToken()); for (int j = 1; j < suppliers; j++) { stringTokenizer = new StringTokenizer(input.readLine()); final int w1 = Integer.valueOf(stringTokenizer.nextToken()); final int w2 = Integer.valueOf(stringTokenizer.nextToken()); final int h1 = Integer.valueOf(stringTokenizer.nextToken()); final int h2 = Integer.valueOf(stringTokenizer.nextToken()); isMajor = ( w1 <= min_w && w2 >= max_w && h1 <= min_h && h2 >= max_h ) || ( isMajor && w1 >= min_w && w2 <= max_w && h1 >= min_h && h2 <= max_h ); min_w = Math.min(min_w, w1); max_w = Math.max(max_w, w2); min_h = Math.min(min_h, h1); max_h = Math.max(max_h, h2); } System.out.println(isMajor ? "TAK" : "NIE"); } } } |