Codeforces Round 254 (Div. 1)


A. DZY Loves Physics
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 0
1
Output
0.000000000000000
Input
2 1
1 2
1 2 1
Output
3.000000000000000
Input
5 6
13 56 73 98 17
1 2 56
1 3 29
1 4 42
2 3 95
2 4 88
3 4 63
Output
2.965517241379311
----------------------------------------------------------------------------------------------------
B. DZY Loves FFT
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1 1
Output
1
3
2
Input
5 4 2
Output
2
2
4
5
5
Input
5 4 3
Output
5
5
5
5
4
----------------------------------------------------------------------------------------------------
C. DZY Loves Colors
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
1 1 2 4
1 2 3 5
2 1 3
Output
8
Input
3 4
1 1 3 4
2 1 1
2 2 2
2 3 3
Output
3
2
1
Input
10 6
1 1 5 3
1 2 7 9
1 10 10 11
1 3 8 12
1 1 10 3
2 1 10
Output
129
----------------------------------------------------------------------------------------------------
D. DZY Loves Strings
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
xudyhduxyz
3
xyz xyz
dyh xyz
dzy xyz
Output
3
8
-1
Input
abcabd
3
a c
ab abc
ab d
Output
2
3
3
Input
baabcabaaa
2
abca baa
aa aba
Output
6
4
----------------------------------------------------------------------------------------------------
E. DZY Loves Planting
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2 1
2 3 2
3 4 3
1
1
1
1
Output
2
Input
4
1 2 1
2 3 2
3 4 3
4
4
4
4
Output
3
----------------------------------------------------------------------------------------------------
