Codeforces Round 245 (Div. 1)


A. Xor-tree
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
2 1
3 1
4 2
5 1
6 2
7 5
8 6
9 8
10 5
1 0 1 1 0 1 0 1 0 1
1 0 1 0 0 1 1 1 0 1
Output
2
4
7
----------------------------------------------------------------------------------------------------
B. Working out
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
100 100 100
100 1 100
100 100 100
Output
800
----------------------------------------------------------------------------------------------------
C. Guess the Tree
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 1 1 4
Output
YES
Input
5
1 1 5 2 1
Output
NO
----------------------------------------------------------------------------------------------------
D. Tricky Function
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 0 0 -1
Output
1
Input
2
1 -1
Output
2
----------------------------------------------------------------------------------------------------
E. Points and Segments
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
0 2
2 3
Output
0 1
Input
6
1 5
1 3
3 5
2 10
11 11
12 12
Output
0 1 0 1 0 0
----------------------------------------------------------------------------------------------------
