The 2021 ICPC Asia Taipei Regional Programming Contest
A. Ice Cream
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
1
1 1 3
Output
6
Input
2
4 7 22
4 8 22
Output
24
24

B. Maximum Sub-Reverse Matching
time limit per test
3 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
5
11
happycoding
onedocument
8
abbbcccd
xcbcbybd
3
cat
dog
4
abcd
xyza
3
dog
pop
Output
2 4 4 8
2 5 2 7
0 0 1 1
0 1 1 4
1 1 1 1

C. Community Service
time limit per test
3 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

D. Largest Remainder
time limit per test
1 с
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
3 1
1 2 3
Output
321
Input
3 10
1 2 3
Output
213
Input
3 100
1 2 3
Output
132

E. Composition with Large Red Plane, Yellow, Black, Gray, and Blue
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
11 7
2
2
0
3 1
0
2 2
0
1 1
Output
***********
*   *     *
*****     *
*   *     *
*   *     *
*   *     *
***********
Input
11 7
2
2
0
3 1
0
2 2
0
1 2
Output
Impossible
Input
34 19
2
2
3
0
7 1
0
11 1
0
9 1
2
3
0
3 3
0
3 5
0
3 5
2
2
0
15 7
2
0
9 3
2
0
4 3
0
4 3
2
2
0
7 3
0
7 3
3
2
0
7 1
0
9 1
2
2
0
7 1
0
7 1
0
9 3
0
17 1
2
0
2 11
0
2 5
Output
**********************************
*       *           *         *  *
*******************************  *
*   *               *         *  *
*   *               *         *  *
*   *               *         *  *
*****               ***********  *
*   *               *    *    *  *
*   *               *    *    *  *
*   *               *    *    *  *
*   ***************************  *
*   *       *       *         *  *
*****       **********************
*   *       *       *         *  *
*   *****************         *  *
*   *       *       *         *  *
*   *       *******************  *
*   *       *                 *  *
**********************************

F. What a Colorful Wall
time limit per test
3 с
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
3
1 6 3 3 1
3 4 6 1 2
2 5 5 2 1
Output
2
Input
3
2 3 3 2 3
1 4 4 1 1
5 4 6 3 2
Output
2
Input
3
0 1 2 0 1
0 1 1 0 2
2 1 3 0 2
Output
2

G. The Treasure of the Sierra Jade
time limit per test
1 с
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
5
2 3
1 2
1 2
0 0
0 0
1
3 0 1 1 1 1 1
2 3
1 2
1 2
0 0
0 0
1
2 0 1 1 1
2 3
1 2
1 2
0 0
1 0
0
2 3
1 2
1 2
0 0
1 0
2
1 0 1
1 1 1
3 3
1 2 1
1 1 1
0 2 0
1 0
1
3 0 1 1 1 2 1
Output
3
-1
2
-1
3

H. A Big Project
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
3 5 2
1 2
6 3
4 3
2 5
5 4
Output
2
1 2
3 4
5 6

I. Seesaw
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
4
3
1 1 3
2 2 2
3
1 1 1
2 2 2
3
1 1 1
4 2 2
3
3 3 3
2 2 2
Output
0
1
2
-1

J. Transportation Network
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Example
Input
2
4 1 1
1
6 2 3
1 4
Output
18
68

K. Insertion Array
time limit per test
3 seconds
memory limit per test
1024 МБ
input
standard input
output
standard output
Example
Input
2
bb
abc
abaa
abab
Output
468235032
667196656

L. Leadfoot
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
5
1 1
2 2
4 6
6 4
12 3
Output
1
1
4
16
1024

M. Escaping the Foggy Forest
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
2 3
1 1 0
0 0 1
1 1 0
Output
0 0
0 1