AIM Tech Round 4 (Div. 2)


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

Examples
Input
yandex
6
Output
0
Input
yahoo
5
Output
1
Input
google
7
Output
impossible
----------------------------------------------------------------------------------------------------
B. Rectangles
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1
0
Output
1
Input
2 3
1 0 1
0 1 0
Output
8
----------------------------------------------------------------------------------------------------
C. Sorting by Subsequences
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
3 2 1 6 5 4
Output
4
2 1 3
1 2
2 4 6
1 5
Input
6
83 -75 -49 11 37 62
Output
1
6 1 2 3 4 5 6
----------------------------------------------------------------------------------------------------
D. Interactive LowerBound
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3 80
97 -1
58 5
16 2
81 1
79 4
Output
? 1
? 2
? 3
? 4
? 5
! 81
----------------------------------------------------------------------------------------------------
E. Upgrading Tree
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

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