Submission details
Task:Monikulmio
Sender:paulajantunen
Submission time:2025-11-08 22:18:56 +0200
Language:Python3 (CPython3)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttimescore
#10.02 s0details
#20.02 s0details
#30.02 s0details
#40.02 s0details
#50.02 s0details
#60.02 s0details
#70.02 s0details
#80.02 s0details
#90.02 s0details
#100.02 s0details

Code

from collections import deque

n, m, k = map(int, input().split())
pts = [tuple(map(int, input().split())) for _ in range(n)]

grid = [['0'] * m for _ in range(n)]

def draw_line(y1, x1, y2, x2):
    dy = y2 - y1
    dx = x2 - x1

    sy = 1 if dy > 0 else -1 if dy < 0 else 0
    sx = 1 if dx > 0 else -1 if dx < 0 else 0

    y, x = y1, x1
    grid[y][x] = '*'

    while (y, x) != (y2, x2):
        y += sy
        x += sx
        if (y, x) == (y2, x2):
            break
        if sy == 0:
            grid[y][x] = '='
        elif sx == 0:
            grid[y][x] = '|'
        elif sy == sx:
            grid[y][x] = '\\'
        else:
            grid[y][x] = '/'

for i in range(k):
    y1, x1 = pts[i]
    y2, x2 = pts[(i + 1) % k]
    draw_line(y1, x1, y2, x2)

for y, x in pts:
    grid[y][x] = '*'

vis = [[False] * m for _ in range(n)]
dq = deque()

for i in range(n):
    dq.append((i, 0))
    dq.append((i, m - 1))
for j in range(m):
    dq.append((0, j))
    dq.append((n - 1, j))

while dq:
    y, x = dq.popleft()
    if not (0 <= y < n and 0 <= x < m):
        continue
    if vis[y][x]:
        continue

    if grid[y][x] not in ('.'):
        continue
    vis[y][x] = True
    for dy, dx in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
        dq.append((y + dy, x + dx))

for i in range(n):
    for j in range(m):
        if grid[i][j] == '.':
            if not vis[i][j]:
                grid[i][j] = '.'
            else:
                grid[i][j] = '#'

for row in grid:
    print("".join(row))

Test details

Test 1 (public)

Verdict:

input
8 9 5
5 2
2 5
5 8
7 8
...

correct output
.........
....*....
.../#\...
../###\..
.*#####*.
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 4, in <module>
    pts = [tuple(map(int, input().split())) for _ in range(n)]
  File "/box/input/code.py", line 4, in <listcomp>
    pts = [tuple(map(int, input().split())) for _ in range(n)]
EOFError: EOF when reading a line

Test 2 (public)

Verdict:

input
20 40 4
5 10
5 30
15 30
15 10

correct output
.................................

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 4, in <module>
    pts = [tuple(map(int, input().split())) for _ in range(n)]
  File "/box/input/code.py", line 4, in <listcomp>
    pts = [tuple(map(int, input().split())) for _ in range(n)]
EOFError: EOF when reading a line

Test 3 (public)

Verdict:

input
20 40 29
8 7
13 2
14 2
9 7
...

correct output
.................................

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 34, in <module>
    y2, x2 = pts[(i + 1) % k]
IndexError: list index out of range

Test 4 (public)

Verdict:

input
20 40 14
5 12
5 25
8 28
13 28
...

correct output
.................................

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 4, in <module>
    pts = [tuple(map(int, input().split())) for _ in range(n)]
  File "/box/input/code.py", line 4, in <listcomp>
    pts = [tuple(map(int, input().split())) for _ in range(n)]
EOFError: EOF when reading a line

Test 5 (public)

Verdict:

input
20 40 12
3 20
7 16
7 9
11 13
...

correct output
.................................

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 4, in <module>
    pts = [tuple(map(int, input().split())) for _ in range(n)]
  File "/box/input/code.py", line 4, in <listcomp>
    pts = [tuple(map(int, input().split())) for _ in range(n)]
EOFError: EOF when reading a line

Test 6 (public)

Verdict:

input
9 35 33
2 3
2 8
4 8
4 5
...

correct output
.................................

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 34, in <module>
    y2, x2 = pts[(i + 1) % k]
IndexError: list index out of range

Test 7 (public)

Verdict:

input
30 100 69
6 10
6 14
7 14
7 18
...

correct output
.................................

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 34, in <module>
    y2, x2 = pts[(i + 1) % k]
IndexError: list index out of range

Test 8 (public)

Verdict:

input
40 60 192
11 3
11 5
10 6
11 7
...

correct output
.................................

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 34, in <module>
    y2, x2 = pts[(i + 1) % k]
IndexError: list index out of range

Test 9 (public)

Verdict:

input
50 100 142
1 1
1 7
1 11
1 14
...

correct output
*=====*===*==*...................

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 34, in <module>
    y2, x2 = pts[(i + 1) % k]
IndexError: list index out of range

Test 10 (public)

Verdict:

input
100 100 1000
10 1
4 7
1 4
1 9
...

correct output
...*====*........................

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 35, in <module>
    draw_line(y1, x1, y2, x2)
  File "/box/input/code.py", line 16, in draw_line
    grid[y][x] = '*'
IndexError: list assignment index out of range