답안 #89344

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
89344 2018-12-11T22:55:53 Z jasony123123 Poklon (COCI17_poklon7) Java 11
84 / 120
1000 ms 177980 KB
import java.util.*;
import java.io.*;
import java.math.*;

class poklon {
	static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer token;
	
	static int N;
	static int[][] C;
	static BigInteger two = new BigInteger("2");
	
	public static void main(String[] args) throws IOException {
		nextLn();
		N = nextInt();
		C = new int[N+1][2];
		for(int i = 1; i<=N; i++) {
			nextLn();
			C[i][0] = nextInt();
			C[i][1] = nextInt();
		}
		BigInteger ans = dfs(1);
		System.out.println(ans.toString(2));
	//	System.out.println(ans);
	}
	
	public static BigInteger dfs(int x) {
		if(x<0) {
			return new BigInteger(Integer.toString(-x));
		}
		BigInteger l = dfs(C[x][0]), r = dfs(C[x][1]);
		BigInteger ans;
		if(l.compareTo(r)>0)
			ans = l;
		else
			ans = r;
		return ans.multiply(two);
	}

	//nextLn moves the token to the nextLine
	public static void nextLn() throws IOException {
		token = new StringTokenizer(reader.readLine());
	}
	//nextInt returns the next available integer
	public static int nextInt() {
		return Integer.parseInt(token.nextToken());
	}
	//nextDouble returns the next available integer
	public static double nextDouble() {
		return Double.parseDouble(token.nextToken());
	}
	//next returns the next word separated by spaces
	public static String next() {
		return token.nextToken();
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 104 ms 10628 KB Output is correct
2 Correct 107 ms 10860 KB Output is correct
3 Correct 103 ms 10860 KB Output is correct
4 Correct 105 ms 10860 KB Output is correct
5 Correct 103 ms 11184 KB Output is correct
6 Correct 105 ms 11264 KB Output is correct
7 Correct 107 ms 11264 KB Output is correct
8 Correct 108 ms 11448 KB Output is correct
9 Correct 119 ms 11620 KB Output is correct
10 Correct 141 ms 13372 KB Output is correct
11 Correct 255 ms 22004 KB Output is correct
12 Correct 244 ms 22004 KB Output is correct
13 Correct 577 ms 58684 KB Output is correct
14 Execution timed out 1025 ms 102880 KB Time limit exceeded
15 Correct 539 ms 102880 KB Output is correct
16 Execution timed out 1087 ms 121640 KB Time limit exceeded
17 Execution timed out 1081 ms 134084 KB Time limit exceeded
18 Execution timed out 1064 ms 136220 KB Time limit exceeded
19 Execution timed out 1140 ms 139932 KB Time limit exceeded
20 Execution timed out 1159 ms 177980 KB Time limit exceeded