ABBYY Cup 2.0 - Easy


A1. Good Matrix Elements
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
4 5 6
7 8 9
Output
45
Input
5
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
Output
17
----------------------------------------------------------------------------------------------------
A2. Good Matrix Elements
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
4 5 6
7 8 9
Output
45
Input
5
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
Output
17
----------------------------------------------------------------------------------------------------
B1. Rectangular Game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
Output
16
Input
8
Output
15
----------------------------------------------------------------------------------------------------
B2. Rectangular Game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
Output
16
Input
8
Output
15
----------------------------------------------------------------------------------------------------
C1. Party
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9
8
1 2
1 3
2 3
4 5
6 7
7 8
8 9
9 6
2
1 6
7 9
Output
3
----------------------------------------------------------------------------------------------------
C2. Party
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9
8
1 2
1 3
2 3
4 5
6 7
7 8
8 9
9 6
2
1 6
7 9
Output
3
----------------------------------------------------------------------------------------------------
D1. Encrypting Messages
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3 2
1 1 1 1
1 1 1
Output
0 1 1 0
Input
3 1 5
1 2 3
4
Output
0 1 2
----------------------------------------------------------------------------------------------------
D2. Encrypting Messages
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3 2
1 1 1 1
1 1 1
Output
0 1 1 0
Input
3 1 5
1 2 3
4
Output
0 1 2
----------------------------------------------------------------------------------------------------
E1. Space Voyage
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 5
1 5
2 4
Output
1
----------------------------------------------------------------------------------------------------
E2. Space Voyage
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 5
1 5
2 4
Output
1
----------------------------------------------------------------------------------------------------
F1. Script Generation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 4 3
1 1 1
1 2 2
2 1 3
2 2 7
Output
2
Input
2 4 7
1 1 1
1 2 2
2 1 3
2 2 7
Output
8
----------------------------------------------------------------------------------------------------
F2. Script Generation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 4 3
1 1 1
1 2 2
2 1 3
2 2 7
Output
2
Input
2 4 7
1 1 1
1 2 2
2 1 3
2 2 7
Output
8
----------------------------------------------------------------------------------------------------
G1. Fibonacci Strings
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 5
a
b
ab
ba
aba
Output
3
5
3
3
1
----------------------------------------------------------------------------------------------------
G2. Fibonacci Strings
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 5
a
b
ab
ba
aba
Output
3
5
3
3
1
----------------------------------------------------------------------------------------------------
