Submission #89340

# Submission time Handle Problem Language Result Execution time Memory
89340 2018-12-11T22:48:49 Z jasony123123 Poklon (COCI17_poklon7) Java 11
0 / 120
108 ms 11536 KB
import java.util.*;
import java.io.*;
import java.math.*;

class ProblemSeven {
	static BufferedReader reader;
	static StringTokenizer token;
	
	static int N;
	static int[][] C;
	
	public static void main(String[] args) throws IOException{
		reader = new BufferedReader(new InputStreamReader(System.in));
		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();
	}
}
# Verdict Execution time Memory Grader output
1 Runtime error 98 ms 10484 KB Execution failed because the return code was nonzero
2 Runtime error 98 ms 10896 KB Execution failed because the return code was nonzero
3 Runtime error 107 ms 11160 KB Execution failed because the return code was nonzero
4 Runtime error 104 ms 11160 KB Execution failed because the return code was nonzero
5 Runtime error 105 ms 11160 KB Execution failed because the return code was nonzero
6 Runtime error 102 ms 11160 KB Execution failed because the return code was nonzero
7 Runtime error 105 ms 11160 KB Execution failed because the return code was nonzero
8 Runtime error 108 ms 11160 KB Execution failed because the return code was nonzero
9 Runtime error 105 ms 11180 KB Execution failed because the return code was nonzero
10 Runtime error 100 ms 11208 KB Execution failed because the return code was nonzero
11 Runtime error 94 ms 11208 KB Execution failed because the return code was nonzero
12 Runtime error 98 ms 11248 KB Execution failed because the return code was nonzero
13 Runtime error 107 ms 11248 KB Execution failed because the return code was nonzero
14 Runtime error 100 ms 11248 KB Execution failed because the return code was nonzero
15 Runtime error 94 ms 11256 KB Execution failed because the return code was nonzero
16 Runtime error 96 ms 11256 KB Execution failed because the return code was nonzero
17 Runtime error 104 ms 11296 KB Execution failed because the return code was nonzero
18 Runtime error 107 ms 11536 KB Execution failed because the return code was nonzero
19 Runtime error 104 ms 11536 KB Execution failed because the return code was nonzero
20 Runtime error 106 ms 11536 KB Execution failed because the return code was nonzero