| Task: | Monikulmio |
| Sender: | Lelleri |
| Submission time: | 2025-10-28 00:08:54 +0200 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | 100 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 100 |
| test | verdict | time | score | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.04 s | 10 | details |
| #2 | ACCEPTED | 0.07 s | 10 | details |
| #3 | ACCEPTED | 0.12 s | 10 | details |
| #4 | ACCEPTED | 0.09 s | 10 | details |
| #5 | ACCEPTED | 0.09 s | 10 | details |
| #6 | ACCEPTED | 0.08 s | 10 | details |
| #7 | ACCEPTED | 0.20 s | 10 | details |
| #8 | ACCEPTED | 0.17 s | 10 | details |
| #9 | ACCEPTED | 0.12 s | 10 | details |
| #10 | ACCEPTED | 0.56 s | 10 | details |
Code
def create_line(x1, y1, x2, y2, grid):
steps = max(abs(x2-x1), abs(y2-y1))
for step in range(1, steps):
x_step = (0 if x2==x1 else (1 if x2>x1 else -1))
y_step = (0 if y2==y1 else (1 if y2>y1 else -1))
dx = x1 + x_step * step
dy = y1 + y_step * step
if(x_step == y_step and x_step == 1 or x_step == y_step and x_step == -1):
grid[dy][dx] = chr(92)
elif(x_step != y_step and x_step != 0 and y_step != 0):
grid[dy][dx] = "/"
elif(x_step == 0):
grid[dy][dx] = "|"
elif(y_step == 0):
grid[dy][dx] = "="
return grid
def between(p1, p2, y):
return p1[1] <= y and y <= p2[1] or p2[1] <= y and y <= p1[1]
n, m, k = [int(i) for i in input().split()]
grid = [["." for _ in range(m)] for _ in range(n)]
points = []
for _ in range(k):
y, x = input().split()
points.append((int(x)-1, int(y)-1))
points.append((points[0][0], points[0][1]))
for i in range(1, len(points)):
point1 = points[i-1]
point2 = points[i]
grid[point1[1]][point1[0]] = "*"
grid = create_line(point1[0], point1[1], point2[0], point2[1], grid)
for row_i in range(n):
for item_i in range(m):
lines = 0
if grid[row_i][item_i] != ".":
continue
for i in range(1, len(points)):
point1 = points[i-1]
point2 = points[i]
y_0 = row_i + (-0.5 if row_i > n//2 else 0.5)
# Checking vertical walls
if(point1[0] == point2[0]):
if(point1[0] < item_i or not between(point1, point2, y_0)):
continue
lines += 1
continue
# Checking horizontal walls
if(point1[1] == point2[1]):
continue
a = (point2[1]-point1[1])/(point2[0]-point1[0])
b = (point1[1]-a*point1[0])
if(item_i >= (row_i-b)//a):
continue
if(between(point1, point2, y_0)):
lines += 1
if grid[row_i][item_i] == "." and lines % 2 == 1:
grid[row_i][item_i] = "#"
for row in grid:
for item in row:
print(f"{item:>1}", end="")
print("\n", end="")
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 |
|---|
| *=====*===*==*................... |
Test 10 (public)
Verdict: ACCEPTED
| input |
|---|
| 100 100 1000 10 1 4 7 1 4 1 9 ... |
| correct output |
|---|
| ...*====*........................ |
| user output |
|---|
| ...*====*........................ |
