Codeforces Round 869 (Div. 2)


A. Politics
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 2
++
+-
1 3
+-+
4 1
+
-
-
+
5 4
++++
+--+
++-+
+-++
++++
4 2
++
--
--
-+
Output
1
1
2
2
1
----------------------------------------------------------------------------------------------------
B. Indivisible
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1
2
3
Output
1
1 2
-1
----------------------------------------------------------------------------------------------------
C. Almost Increasing Subsequence
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9 8
1 2 4 3 3 5 6 2 1
1 3
1 4
2 5
6 6
3 7
7 8
1 8
8 8
Output
3
4
3
1
4
2
7
1
----------------------------------------------------------------------------------------------------
D. Fish Graph
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
7 8
1 2
2 3
3 4
4 1
4 5
4 6
4 2
6 7
7 7
6 7
1 2
2 3
3 4
4 1
1 3
3 5
4 4
1 3
3 4
4 1
1 2
Output
YES
6
5 4
6 4
4 3
1 4
2 1
3 2
YES
5
5 3
2 3
3 1
4 3
1 4
NO
----------------------------------------------------------------------------------------------------
E. Similar Polynomials
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
1000000006 0
2 3
Output
3
Input
2
1 4 9
100 121 144
Output
9
----------------------------------------------------------------------------------------------------
F. Toy Machine
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1
Output
RDL
Input
7 2
Output
RDL
----------------------------------------------------------------------------------------------------
