Codeforces Round 893 (Div. 2)


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

Examples
Input
5
1 1 1
9 3 3
1 2 3
6 6 9
2 2 8
Output
First
First
Second
First
Second
----------------------------------------------------------------------------------------------------
B. The Walkway
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
6 2 2
2 5
8 3 2
3 5 8
10 4 9
2 8 9 10
30 5 8
6 8 15 24 29
30 5 8
6 8 12 20 27
8 8 3
1 2 3 4 5 6 7 8
2 2 2
1 2
1000000000 3 20000000
57008429 66778899 837653445
Output
3 1
4 1
4 4
6 4
5 2
7 7
1 1
51 1
----------------------------------------------------------------------------------------------------
C. Yet Another Permutation Problem
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
5
2
7
10
Output
1 2 4 3 5 
1 2 
1 2 3 6 4 5 7 
1 2 3 4 8 5 10 6 9 7
----------------------------------------------------------------------------------------------------
D. Trees and Segments
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 0
111
4 1
0110
5 0
10000
6 2
101101
7 1
0001101
Output
3 3 3 
4 5 7 9 
5 9 13 17 21 
6 9 13 17 21 25 
7 10 13 17 21 25 29 
----------------------------------------------------------------------------------------------------
E1. Rollbacks (Easy Version)
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
+ 1
+ 2
+ 2
?
!
+ 3
- 2
?
+ 1
?
Output
2
1
1
Input
6
+ 1
+ 1000000
?
!
!
?
Output
2
0
----------------------------------------------------------------------------------------------------
E2. Rollbacks (Hard Version)
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
+ 1
+ 2
+ 2
?
!
+ 3
- 2
?
+ 1
?
Output
2
1
1
Input
6
+ 1
+ 1000000
?
!
!
?
Output
2
0
----------------------------------------------------------------------------------------------------
