Submission details
Task:Monikulmio
Sender:rene
Submission time:2025-11-01 13:53:55 +0200
Language:Python3 (PyPy3)
Status:READY
Result:94
Feedback
groupverdictscore
#1ACCEPTED94
Test results
testverdicttimescore
#1ACCEPTED0.04 s10details
#2ACCEPTED0.05 s10details
#3ACCEPTED0.06 s10details
#4ACCEPTED0.05 s10details
#5ACCEPTED0.05 s10details
#6ACCEPTED0.04 s10details
#7ACCEPTED0.09 s10details
#8ACCEPTED0.09 s10details
#9ACCEPTED0.10 s7details
#10ACCEPTED0.14 s7details

Code

first = input()

first = first.split(" ")
rows = int(first[0])
cols = int(first[1])
points = int(first[2])

matrix = [[0 for _ in range(cols)] for i in range(rows)]
points_list = []

for i in range(points):
  point = input()
  point = point.split(" ")
  x = int(point[0])
  y = int(point[1])
  matrix[x-1][y-1] = 1
  points_list.append((x-1, y-1))

# figure out connecting lines
for i in range(len(points_list)):
  next = (i + 1) % len(points_list)
  if next <= len(points_list):
    next = next
  else:
    next = 0
  x1, y1 = points_list[i]
  x2, y2 = points_list[next]

  # horizontal
  if x1 == x2:
    if y1 < y2:
      temp = y1+1
      while temp < y2:
        matrix[x1][temp] = 2
        temp += 1
    else:
      temp = y1-1
      while temp > y2:
        matrix[x1][temp] = 2
        temp -= 1
  #vertical
  elif y1 == y2:
    if x1 < x2:
      temp = x1+1
      while temp < x2:
        matrix[temp][y1] = 3
        temp += 1
    else:
      temp = x1-1
      while temp > x2:
        matrix[temp][y1] = 3
        temp -= 1
  # diagonals
  else:
    dx = x2 - x1
    dy = y2 - y1
    steps = abs(dx)

    if dx > 0 and dy > 0:
      for d in range(1, steps):
        matrix[x1+d][y1+d] = 4
    elif dx > 0 and dy < 0:
      for d in range(1, steps):
        matrix[x1+d][y1-d] = 5
    elif dx < 0 and dy < 0:
      for d in range(1, steps):
        matrix[x1-d][y1-d] = 4
    else:
      for d in range(1, steps):
        matrix[x1-d][y1+d] = 5

for i in range(points):
  x, y = points_list[i]
  matrix[x][y] = 1

def fill(matrix, start_x, start_y, rows, cols, fill_value):
  stack = [(start_x, start_y)]
  
  while stack:
    x, y = stack.pop()
    if x < 0 or x >= rows or y < 0 or y >= cols:
      continue
    if matrix[x][y] == 0:
      matrix[x][y] = fill_value
      stack.append((x-1, y))
      stack.append((x+1, y))
      stack.append((x, y-1))
      stack.append((x, y+1))

for col in range(cols):
  if matrix[0][col] == 0:
    fill(matrix, 0, col, rows, cols, 7)
  if matrix[rows-1][col] == 0:
    fill(matrix, rows-1, col, rows, cols, 7)

for row in range(rows):
  if matrix[row][0] == 0:
    fill(matrix, row, 0, rows, cols, 7)
  if matrix[row][cols-1] == 0:
    fill(matrix, row, cols-1, rows, cols, 7)

for row in range(rows):
  for col in range(cols):
    if matrix[row][col] == 0:
      matrix[row][col] = 6

for i in range(rows):
  for j in range(cols):
    if matrix[i][j] == 0 or matrix[i][j] == 7:
      print(".", end="")
    elif matrix[i][j] == 1:
      print("*", end="")
    elif matrix[i][j] == 2:
      print("=", end="")
    elif matrix[i][j] == 3:
      print("|", end="")
    elif matrix[i][j] == 4:
      print("\\", end="")
    elif matrix[i][j] == 5:
      print("/", end="")
    elif matrix[i][j] == 6:
      print("#", end="")
  print()

Test details

Test 1 (public)

Verdict: ACCEPTED

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

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

user output
.........
....*....
.../#\...
../###\..
.*#####*.
...

Test 2 (public)

Verdict: ACCEPTED

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

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

user output
.................................

Test 3 (public)

Verdict: ACCEPTED

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

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

user output
.................................

Test 4 (public)

Verdict: ACCEPTED

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

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

user output
.................................

Test 5 (public)

Verdict: ACCEPTED

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

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

user output
.................................

Test 6 (public)

Verdict: ACCEPTED

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

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

user output
.................................

Test 7 (public)

Verdict: ACCEPTED

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

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

user output
.................................

Test 8 (public)

Verdict: ACCEPTED

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

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

user output
.................................

Test 9 (public)

Verdict: ACCEPTED

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

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

user output
*=====*===*==*...................

Feedback: Lines are drawn correctly. Incorrect fill character on row 3, col 9: expected '.', got '#'

Test 10 (public)

Verdict: ACCEPTED

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

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

user output
...*====*........................

Feedback: Lines are drawn correctly. Incorrect fill character on row 4, col 29: expected '.', got '#'