Codeforces Round 789 (Div. 2)


A. Tokitsukaze and All Zero Sequence
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
1 2 3
3
1 2 2
3
1 2 0
Output
4
3
2
----------------------------------------------------------------------------------------------------
B1. Tokitsukaze and Good 01-String (easy version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
10
1110011000
8
11001111
2
00
2
11
6
100110
Output
3
0
0
0
3
----------------------------------------------------------------------------------------------------
B2. Tokitsukaze and Good 01-String (hard version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
10
1110011000
8
11001111
2
00
2
11
6
100110
Output
3 2
0 3
0 1
0 1
3 1
----------------------------------------------------------------------------------------------------
C. Tokitsukaze and Strange Inequality
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
6
5 3 6 1 4 2
4
1 2 3 4
10
5 1 6 2 8 3 4 10 9 7
Output
3
0
28
----------------------------------------------------------------------------------------------------
D. Tokitsukaze and Meeting
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 2
1100
4 2
11001101
2 4
11001101
Output
2 3 4 3
2 3 4 3 5 4 6 5
2 3 3 3 4 4 4 5
----------------------------------------------------------------------------------------------------
E. Tokitsukaze and Two Colorful Tapes
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
6
1 5 4 3 2 6
5 3 1 4 6 2
6
3 5 4 6 2 1
3 6 4 5 2 1
1
1
1
Output
18
10
0
----------------------------------------------------------------------------------------------------
F. Tokitsukaze and Permutations
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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