Codeforces Round 315 (Div. 1)


A. Primes or Palindromes?
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1
Output
40
Input
1 42
Output
1
Input
6 4
Output
172
----------------------------------------------------------------------------------------------------
B. Symmetric and Transitive
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
Output
1
Input
2
Output
3
Input
3
Output
10
----------------------------------------------------------------------------------------------------
C. New Language
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
VC
2 1
1 V 2 C
aa
Output
ab
Input
VC
2 1
1 C 2 V
bb
Output
-1
Input
VCC
4 3
1 C 2 V
2 C 3 V
3 V 4 V
abac
Output
acaa
----------------------------------------------------------------------------------------------------
D. Sign Posts
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1
1 0 0
0 -1 0
7 -93 0
Output
YES
1
1 2
Input
3 1
1 0 0
0 1 0
1 1 3
Output
NO
Input
2 3
3 4 5
5 6 7
Output
YES
2
1 -1
2 -1
----------------------------------------------------------------------------------------------------
E. Longest Increasing Subsequence
time limit per test: 1.5 seconds
memory limit per test: 128 megabytes
input: standard input
output: standard output

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