Codeforces Round 559 (Div. 2)


A. A pile of stones
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
---
Output
0
Input
4
++++
Output
4
Input
2
-+
Output
1
Input
5
++-++
Output
3
----------------------------------------------------------------------------------------------------
B. Expansion coefficient of the array
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
6 4 5 5
Output
1
Input
3
0 1 2
Output
0
Input
4
821 500 479 717
Output
239
----------------------------------------------------------------------------------------------------
C. The Party and Sweets
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 2 1
3 4
Output
12
Input
2 2
0 1
1 0
Output
-1
Input
2 3
1 0
1 1 2
Output
4
----------------------------------------------------------------------------------------------------
D. The minimal unique substring
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
Output
1111
Input
5 3
Output
01010
Input
7 3
Output
1011011
----------------------------------------------------------------------------------------------------
E. Permutation recovery
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
3
2 3 4
2
3 3
3
-1 -1 -1
3
3 4 -1
1
2
4
4 -1 4 5
Output
1 2 3
2 1
2 1 3
-1
1
3 2 1 4
----------------------------------------------------------------------------------------------------
F. Winding polygonal line
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1
3 1
1 3
L
Output
1 2 3
Input
6
1 0
0 1
0 2
-1 0
-1 -1
2 1
RLLR
Output
6 1 3 4 2 5
----------------------------------------------------------------------------------------------------
