Codeforces Round 265 (Div. 1)


A. No to Palindromes!
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
cba
Output
NO
Input
3 4
cba
Output
cbd
Input
4 4
abcd
Output
abda
----------------------------------------------------------------------------------------------------
B. Restore Cube
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
0 0 0
0 0 1
0 0 1
0 0 1
0 1 1
0 1 1
0 1 1
1 1 1
Output
YES
0 0 0
0 0 1
0 1 0
1 0 0
0 1 1
1 0 1
1 1 0
1 1 1
Input
0 0 0
0 0 0
0 0 0
0 0 0
1 1 1
1 1 1
1 1 1
1 1 1
Output
NO
----------------------------------------------------------------------------------------------------
C. Substitutes in Number
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
123123
1
2->00
Output
10031003
Input
123123
1
3->
Output
1212
Input
222
2
2->0
0->7
Output
777
Input
1000000008
0
Output
1
----------------------------------------------------------------------------------------------------
D. World of Darkraft - 2
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 3
Output
1.0000000000
Input
2 1
Output
2.3333333333
Input
10 2
Output
15.9380768924
----------------------------------------------------------------------------------------------------
E. The Classic Problem
time limit per test: 5 seconds
memory limit per test: 768 megabytes
input: standard input
output: standard output

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