(SPOJ) 8704 - Copa do mundo - Solução 2

import java.io.*;
import java.util.*;

class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        Main processando = new Main();
        processando.processa();
       
        System.exit(0);
    }
   
    void processa() throws NumberFormatException, IOException {
        String line = "";
       
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer tokenizer;

        ArrayList<Integer> times1 = new ArrayList<Integer>();
        
        for (int i = 0; i < 8; i++) {
            line = br.readLine();
            tokenizer = new StringTokenizer(line);
            int a = Integer.parseInt(tokenizer.nextToken());
            int b = Integer.parseInt(tokenizer.nextToken());
       
            if (a > b) {
                times1.add(1);
                times1.add(0);
            }
            else {
                times1.add(0);
                times1.add(1);
            }
        }
       
        ArrayList<Integer> times2 = new ArrayList<Integer>();
        
        for (int i = 0; i < 4; i++) {
            line = br.readLine();
            tokenizer = new StringTokenizer(line);
            int a = Integer.parseInt(tokenizer.nextToken());
            int b = Integer.parseInt(tokenizer.nextToken());
       
            if (a > b) {
                times2.add(1);
                times2.add(0);
            }
            else {
                times2.add(0);
                times2.add(1);
            }
        }
       
        ArrayList<Integer> times3 = new ArrayList<Integer>();
        
        for (int i = 0; i < 2; i++) {
            line = br.readLine();
            tokenizer = new StringTokenizer(line);
            int a = Integer.parseInt(tokenizer.nextToken());
            int b = Integer.parseInt(tokenizer.nextToken());
       
            if (a > b) {
                times3.add(1);
                times3.add(0);
            }
            else {
                times3.add(0);
                times3.add(1);
            }
        }
       
        ArrayList<Integer> times4 = new ArrayList<Integer>();
        
        for (int i = 0; i < 1; i++) {
            line = br.readLine();
            tokenizer = new StringTokenizer(line);
            int a = Integer.parseInt(tokenizer.nextToken());
            int b = Integer.parseInt(tokenizer.nextToken());
       
            if (a > b) {
                times4.add(1);
                times4.add(0);
            }
            else {
                times4.add(0);
                times4.add(1);
            }
        }
       
        if (times4.get(0) == 1) {
            if (times3.get(0) == 1) {
                if (times2.get(0) == 1) {
                    if (times1.get(0) == 1) {
                        System.out.println("A");
                    } // 1
                    else {
                        System.out.println("B");
                    }
                } // 1
                else {
                    if (times1.get(2) == 1) {
                        System.out.println("C");
                    }
                    else { // 3
                        System.out.println("D");
                    }
                }
            }
            else {
                if (times2.get(2) == 1) {
                    if (times1.get(4) == 1) {
                        System.out.println("E");
                    }
                    else { //5
                        System.out.println("F");
                    }
                }
                else { // 3
                    if (times1.get(6) == 1) {
                        System.out.println("G");
                    }
                    else { //7
                        System.out.println("H");
                    }
                }               
            }
        }
        else {
            if (times3.get(2) == 1) {
                if (times2.get(4) == 1) {
                    if (times1.get(8) == 1) {
                        System.out.println("I");
                    } // 9
                    else {
                        System.out.println("J");
                    }
                } // 1
                else { // 5
                    if (times1.get(10) == 1) {
                        System.out.println("K");
                    }
                    else { // 11
                        System.out.println("L");
                    }
                }
            }
            else { // 3
                if (times2.get(6) == 1) {
                    if (times1.get(12) == 1) {
                        System.out.println("M");
                    }
                    else { // 13
                        System.out.println("N");
                    }
                }
                else { // 7
                    if (times1.get(14) == 1) {
                        System.out.println("O");
                    }
                    else { // 15
                        System.out.println("P");
                    }
                }               
            }
        }
                                   
        return;
    }
}

Comments

Popular posts from this blog

(Coderbyte) Powers of Two - Solução

(Coderbyte) Dash Insert II - Solução

(CoderByte) Number Search - Solução