Codeforces Round 200 (Div. 1)


A. Rational Resistance
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1
Output
1
Input
3 2
Output
3
Input
199 200
Output
200
----------------------------------------------------------------------------------------------------
B. Alternating Current
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
-++-
Output
Yes
Input
+-
Output
No
Input
++
Output
Yes
Input
-
Output
No
----------------------------------------------------------------------------------------------------
C. Read Time
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4
2 5 6
1 3 6 8
Output
2
Input
3 3
1 2 3
1 2 3
Output
0
Input
1 2
165
142 200
Output
81
----------------------------------------------------------------------------------------------------
D. Water Tree
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2
5 1
2 3
4 2
12
1 1
2 3
3 1
3 2
3 3
3 4
1 2
2 4
3 1
3 3
3 4
3 5
Output
0
0
0
1
0
1
0
1
----------------------------------------------------------------------------------------------------
E. Pumping Stations
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 11
1 2 10
1 6 8
2 3 4
2 5 2
2 6 3
3 4 5
3 5 4
3 6 2
4 5 7
4 6 2
5 6 3
Output
77
6 2 1 5 3 4 
----------------------------------------------------------------------------------------------------
