Submission details
Task:Monikulmio
Sender:Joh
Submission time:2025-10-28 19:18:31 +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

def draw_line(grid, y1, x1, y2, x2):
    # Calculate direction
    dy = 0 if y1 == y2 else (1 if y2 > y1 else -1)
    dx = 0 if x1 == x2 else (1 if x2 > x1 else -1)
    if dy == 0:  
        char = '='
    elif dx == 0:
        char = '|'
    elif dy * dx > 0:
        char = '\'
    else:
        char = '/'
    y, x = y1 + dy, x1 + dx
    while (y, x) != (y2, x2):
        grid[y][x] = char
        y += dy
        x += dx
 
def is_inside_polygon(y, x, grid, n, m):
    if grid[y][x] != '.':
        return False
    crossings = 0
    for cx in range(x + 1, m):
        cell = grid[y][cx]
        if cell == '|':
            crossings += 1
        elif cell == '/':
            if y > 0 and cx > 0 and grid[y-1][cx-1] in '|\/' :
                crossings += 1
        elif cell == '\':
            if y > 0 and cx < m-1 and grid[y-1][cx+1] in '|\/' :
                crossings += 1
        elif cell == '':
            above = grid[y-1][cx] if y > 0 else '.'
            below = grid[y+1][cx] if y < n-1 else '.'
            if above == '|' or below == '|':
                crossings += 1
            elif (above in '/\' and below in '/\'):
                crossings += 1

    return crossings % 2 == 1
 
def solve():
    n, m, k = map(int, input().split())
    corners = []
    for  in range(k):
        y, x = map(int, input().split())
        corners.append((y-1, x-1))
    grid = [['.' for  in range(m)] for _ in range(n)]
    for y, x in corners:
        grid[y][x] = ''
    for i in range(k):
        y1, x1 = corners[i]
        y2, x2 = corners[(i + 1) % k]
        draw_line(grid, y1, x1, y2, x2)
    for y in range(n):
        for x in range(m):
            if is_inside_polygon(y, x, grid, n, m):
                grid[y][x] = '#'
    for row in grid:
        print(''.join(row))
 
solve()

Test details

Test 1 (public)

Verdict:

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

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

user output
(empty)

Error:
File "/box/input/code.py", line 10
    char = '\'
           ^
SyntaxError: unterminated string literal (detected at line 10)

Test 2 (public)

Verdict:

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

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

user output
(empty)

Error:
File "/box/input/code.py", line 10
    char = '\'
           ^
SyntaxError: unterminated string literal (detected at line 10)

Test 3 (public)

Verdict:

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

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

user output
(empty)

Error:
File "/box/input/code.py", line 10
    char = '\'
           ^
SyntaxError: unterminated string literal (detected at line 10)

Test 4 (public)

Verdict:

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

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

user output
(empty)

Error:
File "/box/input/code.py", line 10
    char = '\'
           ^
SyntaxError: unterminated string literal (detected at line 10)

Test 5 (public)

Verdict:

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

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

user output
(empty)

Error:
File "/box/input/code.py", line 10
    char = '\'
           ^
SyntaxError: unterminated string literal (detected at line 10)

Test 6 (public)

Verdict:

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

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

user output
(empty)

Error:
File "/box/input/code.py", line 10
    char = '\'
           ^
SyntaxError: unterminated string literal (detected at line 10)

Test 7 (public)

Verdict:

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

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

user output
(empty)

Error:
File "/box/input/code.py", line 10
    char = '\'
           ^
SyntaxError: unterminated string literal (detected at line 10)

Test 8 (public)

Verdict:

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

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

user output
(empty)

Error:
File "/box/input/code.py", line 10
    char = '\'
           ^
SyntaxError: unterminated string literal (detected at line 10)

Test 9 (public)

Verdict:

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

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

user output
(empty)

Error:
File "/box/input/code.py", line 10
    char = '\'
           ^
SyntaxError: unterminated string literal (detected at line 10)

Test 10 (public)

Verdict:

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

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

user output
(empty)

Error:
File "/box/input/code.py", line 10
    char = '\'
           ^
SyntaxError: unterminated string literal (detected at line 10)