Hello 2024


A. Wallet Exchange
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
1 1
1 4
5 3
4 5
11 9
83 91
1032 9307
839204 7281
1000000000 1000000000
53110 2024
Output
Bob
Alice
Bob
Alice
Bob
Bob
Alice
Alice
Bob
Bob
----------------------------------------------------------------------------------------------------
B. Plus-Minus Split
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1
+
5
-----
6
+-+-+-
10
--+++++++-
20
+---++++-+++++---++-
Output
1
5
0
4
4
----------------------------------------------------------------------------------------------------
C. Grouping Increases
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
5
1 2 3 4 5
8
8 2 3 1 1 7 4 3
5
3 3 3 3 3
1
1
2
2 1
Output
3
1
0
0
0
----------------------------------------------------------------------------------------------------
D. 01 Tree
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5
2 1 0 1 1
5
1 0 2 1 3
Output
YES
NO
----------------------------------------------------------------------------------------------------
E. Counting Prefixes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1
0
1
1
3
-1 1 2
5
-1 0 0 1 1
5
-4 -3 -3 -2 -1
Output
0
1
0
3
1
----------------------------------------------------------------------------------------------------
F1. Wine Factory (Easy Version)
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 3
3 3 3 3
1 4 2 8
1000000000000000000 1000000000000000000 1000000000000000000
4 3 8 1000000000000000000
2 5 1 1000000000000000000
3 0 0 1000000000000000000
Output
12
12
10
Input
5 5
10 3 8 9 2
3 4 10 8 1
1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000
5 4 9 1000000000000000000
1 1 1 1000000000000000000
2 7 4 1000000000000000000
4 1 1 1000000000000000000
1 8 3 1000000000000000000
Output
34
25
29
21
27
----------------------------------------------------------------------------------------------------
F2. Wine Factory (Hard Version)
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 3
3 3 3 3
1 4 2 8
5 2 1
4 3 8 1000000000
2 5 1 1
3 0 0 0
Output
11
8
5
Input
5 5
10 3 8 9 2
3 4 10 8 1
6 5 9 2
5 4 9 1
1 1 1 1
2 7 4 8
4 1 1 1
1 8 3 3
Output
31
25
29
21
23
----------------------------------------------------------------------------------------------------
G. Tree LGM
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1100
0101
0011
0101
Output
YES
4 1
3 2
2 4
Input
3
001
010
100
Output
NO
----------------------------------------------------------------------------------------------------
H. Tree Diameter
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
1
9
0
Output
? 1 1 1 1 1
? 2 1 3
? 1 4 3 2 1
? 2 4 2
!
3 1
4 2
1 2
2 5
----------------------------------------------------------------------------------------------------
