Codeforces Round 809 (Div. 2)


A. Another String Minimization Problem
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
4 5
1 1 3 1
1 5
2
4 1
1 1 1 1
2 4
1 3
2 7
7 5
4 5
5 5 3 5
Output
ABABA
BABBB
A
AABB
ABABBBB
ABABA
----------------------------------------------------------------------------------------------------
B. Making Towers
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
7
1 2 3 1 2 3 1
6
4 2 2 2 4 4
1
1
5
5 4 5 3 5
6
3 3 3 1 3 3
8
1 2 3 4 4 3 2 1
Output
3 2 2 0 0 0 0 
0 3 0 2 0 0 
1 
0 0 1 1 1 
1 0 4 0 0 0 
2 2 2 2 0 0 0 0 
----------------------------------------------------------------------------------------------------
C. Qpwoeirut And The City
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
3
2 1 2
5
1 2 1 4 3
6
3 1 4 5 5 2
8
4 2 1 3 5 3 6 1
6
1 10 1 1 10 1
8
1 10 11 1 10 11 10 1
Output
2
0
3
3
0
4
----------------------------------------------------------------------------------------------------
D1. Chopping Carrots (Easy Version)
time limit per test: 4 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
7
5 2
4 5 6 8 11
5 12
4 5 6 8 11
3 1
2 9 15
7 3
2 3 5 5 6 9 10
6 56
54 286 527 1436 2450 2681
3 95
16 340 2241
2 2
1 3
Output
2
0
13
1
4
7
0
----------------------------------------------------------------------------------------------------
D2. Chopping Carrots (Hard Version)
time limit per test: 4 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
7
5 2
4 5 6 8 11
5 12
4 5 6 8 11
3 1
2 9 15
7 3
2 3 5 5 6 9 10
6 56
54 286 527 1436 2450 2681
3 95
16 340 2241
2 2
1 3
Output
2
0
13
1
4
7
0
----------------------------------------------------------------------------------------------------
E. Qpwoeirut and Vertices
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 1 2
1 2
1 1
1 2
5 5 5
1 2
1 3
2 4
3 4
3 5
1 4
3 4
2 2
2 5
3 5
3 2 1
1 3
2 3
1 3
Output
0 1 
3 3 0 5 5 
2 
----------------------------------------------------------------------------------------------------
