Skip to content

Turning Red

Unrated
English

Language

Contribute a translation
Time limit
3000 ms
Memory limit
2048 MB (no extra memory)
Submissions
0
Correct
0
Solved by
0
AC rate
—

Statement

Turning Red, page 1

Turning Red, page 2

Examples

Sample input 1
8 6
GBRBRRRG
2 1 4
1 2
4 4 5 6 7
3 5 6 7
1 8
1 8
Sample output 1
8
Sample input 2
4 3
RGBR
2 1 2
2 2 3
2 3 4
Sample output 2
impossible
Sample input 3
4 4
GBRG
2 1 2
2 2 3
2 3 4
1 4
Sample output 3
6
Sample input 4
3 3
RGB
1 1
1 2
1 3
Sample output 4
3

Tags

No tags yet

Source