답안 #89342

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
89342 2018-12-11T22:53:06 Z jasony123123 Poklon (COCI17_poklon7) Java 11
90 / 120
1000 ms 159588 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;
	
	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(new BigInteger("2"));
	}

	//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 95 ms 10616 KB Output is correct
2 Correct 92 ms 11088 KB Output is correct
3 Correct 97 ms 11200 KB Output is correct
4 Correct 97 ms 11392 KB Output is correct
5 Correct 99 ms 11512 KB Output is correct
6 Correct 101 ms 11512 KB Output is correct
7 Correct 105 ms 11740 KB Output is correct
8 Correct 107 ms 11740 KB Output is correct
9 Correct 113 ms 11928 KB Output is correct
10 Correct 161 ms 13576 KB Output is correct
11 Correct 238 ms 22536 KB Output is correct
12 Correct 266 ms 22836 KB Output is correct
13 Correct 579 ms 55844 KB Output is correct
14 Correct 947 ms 107488 KB Output is correct
15 Correct 557 ms 107488 KB Output is correct
16 Execution timed out 1077 ms 126364 KB Time limit exceeded
17 Execution timed out 1180 ms 146012 KB Time limit exceeded
18 Execution timed out 1218 ms 159588 KB Time limit exceeded
19 Execution timed out 1129 ms 159588 KB Time limit exceeded
20 Execution timed out 1212 ms 159588 KB Time limit exceeded