Hos' Xmas Contest 2010 H "Read Me"

問題:http://judge.imoz.jp/page.php?page=view_problem&pid=68&cid=12

昼の部に参加.

import java.util.*;

// H "Read Me"
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		for (;;) {
			String str = s.nextLine();
			if (str.contains("@")) {
				break;
			}
			List<String> list = new ArrayList<String>();
			for (; !str.contains("@"); str = s.nextLine()) {
				list.add(str);
			}
			String r = "?";
			String[] sp = list.get(0).split(" ");
			if (list.get(list.size() - 1).contains("#")) {
				r = "B";
			} else if (sp.length == 2) {
				r = "C";
			} else if (sp.length == 1) {
				r = "E";
			} else if (sp.length == 3) {
				r = "F";
			} else if (list.size() > 1) {
				if(list.get(1).split(" ").length == 3){
					r = "D";
				}else if(list.size() > 21){
					r = "A";
				}else{
					for(String line : list){
						sp = line.split(" ");
						int n = new Integer(sp[0]);
						int m = new Integer(sp[1]);
						int a = new Integer(sp[2]);
						int b = new Integer(sp[3]);
						if(n > 100000 || m > 100000 || a > n || b > n){
							r = "A";
							break;
						}
					}
				}
			}
			System.out.println(r);
		}
	}
}