2022 ICPC World Finals
P. Turning Red
time limit per test
3 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
8 6
GBRBRRRG
2 1 4
1 2
4 4 5 6 7
3 5 6 7
1 8
1 8
Output
8
Input
4 3
RGBR
2 1 2
2 2 3
2 3 4
Output
impossible
Input
4 4
GBRG
2 1 2
2 2 3
2 3 4
1 4
Output
6
Input
3 3
RGB
1 1
1 2
1 3
Output
3

Q. Doing the Container Shuffle
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
5
4 2 5 3 1
Output
7.000
Input
6
1 2 3 4 5 6
Output
13.500

R. Zoo Management
time limit per test
5 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
3 3
1 4
4 7
7 1
1 2
2 3
1 3
Output
possible
Input
2 1
1 2
2 1
1 2
Output
impossible
Input
5 6
10 40
20 30
30 50
40 20
50 10
1 2
2 3
1 3
3 4
3 5
4 5
Output
possible
Input
4 4
10 10
10 20
20 10
20 20
1 2
2 3
3 4
1 4
Output
impossible

S. Bridging the Gap
time limit per test
4 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
4 2
1 2 10 5
Output
17
Input
4 6
1 2 10 5
Output
10

T. Carl's Vacation
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
0 0 10 0 4
9 18 34 26 42
Output
60.866649532

U. Toy Train Tracks
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
4 12
Output
LRLLRSSLLSSRLLRL
Input
1 5
Output
LLLL

V. Three Kinds of Dice
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
6 1 1 6 6 8 8
3 2 4 9
Output
0.291666667 0.750000000
Input
4 9 3 7 5
3 4 2 3
Output
0.500000000 0.500000000

W. Riddle of the Sphinx
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

X. Quartets
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
4
1 A 2 3C no
2 A 3 3A yes
2 A 4 3D yes
2 A 1 3C no
Output
no
4
Input
6
1 A 2 3C no
2 A 3 3A yes
2 A 4 3D yes
2 A 1 3B no
1 A 4 5B yes
1 Q 5
Output
yes

Y. Compression
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
1111
Output
1
Input
101
Output
101
Input
10110
Output
10

Z. Archaeological Recovery
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
2 3 4
EEE 1
EIA 1
IAE 1
AAA 1
Output
+++
+-0
Input
3 2 2
IA 4
AA 4
Output
00
00
-0