Submission details
Task:Modern art
Sender:aalto26jm_020
Submission time:2026-11-09 17:32:15 +0200
Language:Python3 (PyPy3)
Status:READY
Result:
Test results
testverdicttime
#10.07 sdetails
#20.07 sdetails
#30.07 sdetails
#4ACCEPTED0.04 sdetails
#50.07 sdetails
#60.07 sdetails
#70.07 sdetails
#80.07 sdetails
#90.04 sdetails
#100.07 sdetails
#11ACCEPTED0.04 sdetails
#120.07 sdetails
#130.07 sdetails
#140.04 sdetails
#15ACCEPTED0.04 sdetails
#160.07 sdetails
#17ACCEPTED0.04 sdetails
#180.07 sdetails
#190.04 sdetails
#200.07 sdetails
#21ACCEPTED0.04 sdetails
#220.07 sdetails
#230.07 sdetails
#240.07 sdetails
#25ACCEPTED0.04 sdetails
#260.07 sdetails
#270.07 sdetails
#280.07 sdetails
#290.07 sdetails
#300.07 sdetails
#310.07 sdetails
#320.07 sdetails
#330.07 sdetails
#340.07 sdetails
#35ACCEPTED0.04 sdetails
#360.07 sdetails
#37ACCEPTED0.04 sdetails
#380.07 sdetails
#390.07 sdetails
#400.07 sdetails
#41ACCEPTED0.04 sdetails
#420.08 sdetails
#430.07 sdetails
#440.07 sdetails
#45ACCEPTED0.04 sdetails
#460.07 sdetails
#47ACCEPTED0.04 sdetails
#480.07 sdetails
#490.07 sdetails
#500.07 sdetails

Code

A, P = map(int, input().split())

answer = None
if P % 2 == 0:
    s = P // 2
    best_key = None
    for W in range(1, s):
        h = s - W

        key = (abs(W - h), -W)  
        if best_key is None or key < best_key:
            best_key = key
            answer = (W, h)

if answer is None:
    print("IMPOSSIBLE")
else:
    W, h = answer
    grid = [[0] * W for _ in range(h)]

    for r in range(1, h):
        for c in range(W - 2, -1, -1):
            if left > 0:
                grid[r][c] = 1
                left -= 1

    print("POSSIBLE")
    print("0" * (W + 2))
    for row in grid:
        print("0" + "".join(map(str, row)) + "0")
    print("0" * (W + 2))

Test details

Test 1

Verdict:

input
5 14

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 2

Verdict:

input
6 14

correct output
POSSIBLE
000
010
010
010
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 3

Verdict:

input
7 10

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 4

Verdict: ACCEPTED

input
5 5

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 5

Verdict:

input
6 22

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 6

Verdict:

input
7 10

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 7

Verdict:

input
5 20

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 8

Verdict:

input
6 8

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 9

Verdict:

input
7 4

correct output
IMPOSSIBLE

user output
POSSIBLE
000
000
000

Test 10

Verdict:

input
5 10

correct output
POSSIBLE
0000
0110
0110
0100
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 11

Verdict: ACCEPTED

input
10 25

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 12

Verdict:

input
10 22

correct output
POSSIBLE
000
010
010
010
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 13

Verdict:

input
10 14

correct output
POSSIBLE
0000
0110
0110
0110
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 14

Verdict:

input
10 6

correct output
IMPOSSIBLE

user output
POSSIBLE
0000
0000
0000

Test 15

Verdict: ACCEPTED

input
10 37

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 16

Verdict:

input
10 12

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 17

Verdict: ACCEPTED

input
10 39

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 18

Verdict:

input
10 14

correct output
POSSIBLE
0000
0110
0110
0110
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 19

Verdict:

input
10 4

correct output
IMPOSSIBLE

user output
POSSIBLE
000
000
000

Test 20

Verdict:

input
10 16

correct output
POSSIBLE
00000000
01111110
01111000
00000000

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 21

Verdict: ACCEPTED

input
100 239

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 22

Verdict:

input
100 202

correct output
POSSIBLE
000
010
010
010
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 23

Verdict:

input
100 70

correct output
POSSIBLE
000000000000000000000000000000...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 24

Verdict:

input
100 32

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 25

Verdict: ACCEPTED

input
100 361

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 26

Verdict:

input
100 48

correct output
POSSIBLE
00000000000000000000
01111111111111111110
01111111111111111110
01111111111111111110
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 27

Verdict:

input
100 380

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 28

Verdict:

input
100 76

correct output
POSSIBLE
000000000000000000000000000000...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 29

Verdict:

input
100 8

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 30

Verdict:

input
100 98

correct output
POSSIBLE
000000000000000000000000000000...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 31

Verdict:

input
200 476

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 32

Verdict:

input
200 402

correct output
POSSIBLE
000
010
010
010
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 33

Verdict:

input
200 120

correct output
POSSIBLE
000000000000000000000000000000...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 34

Verdict:

input
200 60

correct output
POSSIBLE
000000000000
011111111110
011111111110
011111111110
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 35

Verdict: ACCEPTED

input
200 721

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 36

Verdict:

input
200 74

correct output
POSSIBLE
000000000000000000000000000000...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 37

Verdict: ACCEPTED

input
200 759

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 38

Verdict:

input
200 134

correct output
POSSIBLE
000000000000000000000000000000...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 39

Verdict:

input
200 12

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 40

Verdict:

input
200 182

correct output
POSSIBLE
000000000000000000000000000000...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 41

Verdict: ACCEPTED

input
1000 2373

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 42

Verdict:

input
1000 1998

correct output
POSSIBLE
000000000000000000000000000000...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 43

Verdict:

input
1000 472

correct output
POSSIBLE
000000000000000000000000000000...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 44

Verdict:

input
1000 286

correct output
POSSIBLE
000000000000000000000000000000...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 45

Verdict: ACCEPTED

input
1000 3603

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 46

Verdict:

input
1000 228

correct output
POSSIBLE
000000000000000000000000000000...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 47

Verdict: ACCEPTED

input
1000 3791

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 48

Verdict:

input
1000 552

correct output
POSSIBLE
000000000000000000000000000000...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 49

Verdict:

input
1000 48

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?

Test 50

Verdict:

input
1000 810

correct output
POSSIBLE
000000000000000000000000000000...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 23, in <module>
    if left > 0:
NameError: name 'left' is not defined. Did you mean: len?