Codeforces Round 354 (Div. 2)


A. Nicholas and Permutation
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4 5 1 3 2
Output
3
Input
7
1 6 5 3 4 7 2
Output
6
Input
6
6 5 4 3 2 1
Output
5
----------------------------------------------------------------------------------------------------
B. Pyramid of Glasses
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5
Output
4
Input
4 8
Output
6
----------------------------------------------------------------------------------------------------
C. Vasya and String
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
abba
Output
4
Input
8 1
aabaabaa
Output
5
----------------------------------------------------------------------------------------------------
D. Theseus and labyrinth
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
+*
*U
1 1
2 2
Output
-1
Input
2 3
<><
><>
1 1
2 1
Output
4
----------------------------------------------------------------------------------------------------
E. The Last Fight Between Human and AI
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 2
-1
?
Output
Yes
Input
2 100
-10000
0
1
Output
Yes
Input
4 5
?
1
?
1
?
Output
No
----------------------------------------------------------------------------------------------------
