VK Cup 2015 - Finals, online mirror


A. Matching Names
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
gennady
galya
boris
bill
toshik
bilbo
torin
gendalf
smaug
galadriel
Output
11
4 1
2 5
1 3
5 2
3 4
----------------------------------------------------------------------------------------------------
B. Replicating Processes
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2 2
1 2 2
1 2 2
1 2 2
2 1 1
2 1 1
2 1 1
2 1 1
Output
YES
1 2 5 6 3 7 4 8
Input
3
1 2 3
1 1 1
1 1 1
1 1 1
2 1 3
2 2 2
2 2 2
2 2 2
3 1 2
3 3 3
3 3 3
3 3 3
Output
YES
2 3 4 6 7 8 10 11 12 1 5 9
----------------------------------------------------------------------------------------------------
C. Logistical Questions
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 1 2 6 5
1 2 3
2 3 1
4 3 9
5 3 1
Output
3 192.0
Input
2
5 5
1 2 2
Output
1 14.142135623730951000
----------------------------------------------------------------------------------------------------
D. Restructuring Company
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 6
3 2 5
1 2 5
3 2 5
2 4 7
2 1 2
3 1 7
Output
NO
YES
YES
----------------------------------------------------------------------------------------------------
E. Restoring Map
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4 3 2 4 1
5 5 3 2 4 1
5 4 2 1 5 3
4 2 1 4 3
3 1 4 5
Output
1 4
1 2
1 3
4 5
Input
6
5 6 1 3 4 2
5 2 1 3 4 6
6 3 6 2 5 4 1
6 6 1 2 5 3 4
3 5 2 4
5 3 1 2 4 6
Output
2 4
1 2
2 3
2 6
4 5
----------------------------------------------------------------------------------------------------
F. Clique in the Divisibility Graph
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
3 4 6 8 10 18 21 24
Output
3
----------------------------------------------------------------------------------------------------
G. Max and Min
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
42 43
2 3
3 2
3 10
10 3
Output
Min
Input
1 1
1 1
3 4
1 1
Output
Max
----------------------------------------------------------------------------------------------------
