VK Cup 2012 Round 2


A. Substring and Subsequence
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
aa
aa
Output
5
Input
codeforces
forceofcode
Output
60
----------------------------------------------------------------------------------------------------
B. Lemmings
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3 2
1 2 3 2 1
1 2 1 2 10
Output
5 2 4
Input
5 3 10
3 4 3 2 1
5 4 3 2 1
Output
4 3 1
----------------------------------------------------------------------------------------------------
C. Conveyor
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1 1 1
0
Output
0.75000000000000000000
0.25000000000000000000
Input
2 3 1 2
2 5
Output
0.33333333333333331000
0.66666666666666663000
0.00000000000000000000
----------------------------------------------------------------------------------------------------
D. Large Refrigerator
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1
2 3
1
17 1
3
3 1
2 3
5 1
Output
24 2 2 2
70 1 1 17
148 4 6 5
----------------------------------------------------------------------------------------------------
E. e-Government
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 3
a
aa
ab
?aaab
-2
?aaab
-3
?aaab
+2
?aabbaa
Output
6
4
3
6
----------------------------------------------------------------------------------------------------
