Codeforces Round 278 (Div. 1)


A. Fight the Monster
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 2 1
1 100 1
1 100 100
Output
99
Input
100 100 100
1 1 1
1 1 1
Output
0
----------------------------------------------------------------------------------------------------
B. Strip
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 2 2
1 3 1 2 4 1 2
Output
3
Input
7 2 2
1 100 1 100 1 100 1
Output
-1
----------------------------------------------------------------------------------------------------
C. Prefix Product Sequence
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
Output
YES
1
4
3
6
5
2
7
Input
6
Output
NO
----------------------------------------------------------------------------------------------------
D. Conveyor Belts
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2 3
>>
^^
A 2 1
C 1 2 <
A 2 1
Output
1 3
-1 -1
Input
4 5 7
><<^<
^<^^>
>>>^>
>^>>^
A 3 1
A 2 2
C 1 4 <
A 3 1
C 1 2 ^
A 3 1
A 2 2
Output
0 4
-1 -1
-1 -1
0 2
0 2
----------------------------------------------------------------------------------------------------
E. Tourists
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 3
1
2
3
1 2
2 3
1 3
A 2 3
C 1 5
A 2 3
Output
1
2
Input
7 9 4
1
2
3
4
5
6
7
1 2
2 5
1 5
2 3
3 4
2 4
5 6
6 7
5 7
A 2 3
A 6 4
A 6 7
A 3 3
Output
2
1
5
3
----------------------------------------------------------------------------------------------------
