Educational Codeforces Round 4


A. The Text Splitting
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2 3
Hello
Output
2
He
llo
Input
10 9 5
Codeforces
Output
2
Codef
orces
Input
6 4 5
Privet
Output
-1
Input
8 1 1
abacabac
Output
8
a
b
a
c
a
b
a
c
----------------------------------------------------------------------------------------------------
B. HDD is Outdated Technology
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 1 2
Output
3
Input
5
1 3 5 4 2
Output
10
----------------------------------------------------------------------------------------------------
C. Replace To Make Regular Bracket Sequence
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
[<}){}
Output
2
Input
{()}[]
Output
0
Input
]]
Output
Impossible
----------------------------------------------------------------------------------------------------
D. The Union of k-Segments
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
0 5
-3 2
3 8
Output
2
0 2
3 5
Input
3 2
0 5
-3 3
3 8
Output
1
0 5
----------------------------------------------------------------------------------------------------
E. Square Root of Permutation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 1 4 3
Output
3 4 2 1
Input
4
2 1 3 4
Output
-1
Input
5
2 3 4 5 1
Output
4 5 1 2 3
----------------------------------------------------------------------------------------------------
F. Simba on the Circle
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9 1
0 1 2 2 2 1 0 1 1
Output
12
+0
-3
-1
+2
+1
+2
+1
+1
+1
Input
8 1
0 1 0 1 0 1 0 1
Output
13
+0
+2
+2
+2
-1
+2
+2
+2
Input
8 1
1 2 3 4 5 6 7 8
Output
7
+0
+1
+1
+1
+1
+1
+1
+1
Input
8 1
0 0 0 0 0 0 0 0
Output
7
+0
+1
+1
+1
+1
+1
+1
+1
----------------------------------------------------------------------------------------------------
