Submission details
Task:Monikulmio
Sender:PuskaJamal
Submission time:2025-11-03 00:19:41 +0200
Language:Python3 (PyPy3)
Status:READY
Result:70
Feedback
groupverdictscore
#1ACCEPTED70
Test results
testverdicttimescore
#1ACCEPTED0.05 s7details
#2ACCEPTED0.09 s7details
#3ACCEPTED0.08 s7details
#4ACCEPTED0.08 s7details
#5ACCEPTED0.08 s7details
#6ACCEPTED0.06 s7details
#7ACCEPTED0.14 s7details
#8ACCEPTED0.14 s7details
#9ACCEPTED0.18 s7details
#10ACCEPTED0.32 s7details

Code

import sys
sys.setrecursionlimit(5000)
# Koodi, joka toimii:
s = input()
s = s.split()
b = []
for i in range(int(s[0])):
    b.append("."*int(s[1]))
c = [0, 0]
for i in range(int(s[2])):
    d = input()
    e = d.split()
    e = [int(e[0]), int(e[1])]
    if c == [0, 0]:
        c = [int(e[0]), int(e[1])]
        u = c
    f = b[e[0]-1]
    f = f[: e[1]-1] + '*' + f[e[1]:]
    b[e[0]-1] = f
    if i != int(s[2]):
        if e != c:
            if e[0] == c[0]:
                if c[1]-e[1] < 0:
                    for i in range(e[1]-c[1]-1):
                        c = [c[0], c[1]+1]
                        f = b[c[0]-1]
                        f = f[: c[1]-1] + '=' + f[c[1]:]
                        b[e[0]-1] = f
                    c = [c[0], c[1]+1]
                elif c[1]-e[1] > 0:
                    for i in range(c[1]-e[1]-1):
                        c = [c[0], c[1]-1]
                        f = b[c[0]-1]
                        f = f[: c[1]-1] + '=' + f[c[1]:]
                        b[e[0]-1] = f
                    c = [c[0], c[1]-1]
            elif e[1] == c[1]:
                if c[0]-e[0] < 0:
                    for i in range(e[0]-c[0]-1):
                        c = [c[0]+1, c[1]]
                        f = b[c[0]-1]
                        f = f[: c[1]-1] + '|' + f[c[1]:]
                        b[c[0]-1] = f
                    c = [c[0]+1, c[1]]
                elif c[0]-e[0] > 0:
                    for i in range(c[0]-e[0]-1):
                        c = [c[0]-1, c[1]]
                        f = b[c[0]-1]
                        f = f[: c[1]-1] + '|' + f[c[1]:]
                        b[c[0]-1] = f
                    c = [c[0]-1, c[1]]
            elif e[0]-c[0] == e[1]-c[1]:
                if e[0]-c[0] > 0:
                    for i in range(e[0]-c[0]-1):
                        c = [c[0]+1, c[1]+1]
                        f = b[c[0]-1]
                        f = f[: c[1]-1] + '\\' + f[c[1]:]
                        b[c[0]-1] = f
                    c = [c[0]+1, c[1]+1]
                elif e[0]-c[0] < 0:
                    for i in range(c[0]-e[0]-1):
                        c = [c[0]-1, c[1]-1]
                        f = b[c[0]-1]
                        f = f[: c[1]-1] + '\\' + f[c[1]:]
                        b[c[0]-1] = f
                    c = [c[0]-1, c[1]-1]
            elif c[0]-e[0] == e[1]-c[1]:
                if e[0]-c[0] < 0:
                    for i in range(c[0]-e[0]-1):
                        c = [c[0]-1, c[1]+1]
                        f = b[c[0]-1]
                        f = f[: c[1]-1] + '/' + f[c[1]:]
                        b[c[0]-1] = f
                    c = [c[0]-1, c[1]+1]
                elif e[0]-c[0] > 0:
                    for i in range(e[0]-c[0]-1):
                        c = [c[0]+1, c[1]-1]
                        f = b[c[0]-1]
                        f = f[: c[1]-1] + '/' + f[c[1]:]
                        b[c[0]-1] = f
                    c = [c[0]+1, c[1]-1]
else:
    if u[0] == c[0]:
                if c[1]-u[1] < 0:
                    for i in range(u[1]-c[1]-1):
                        c = [c[0], c[1]+1]
                        f = b[c[0]-1]
                        f = f[: c[1]-1] + '=' + f[c[1]:]
                        b[u[0]-1] = f
                    c = [c[0], c[1]+1]
                elif c[1]-u[1] > 0:
                    for i in range(c[1]-u[1]-1):
                        c = [c[0], c[1]-1]
                        f = b[c[0]-1]
                        f = f[: c[1]-1] + '=' + f[c[1]:]
                        b[u[0]-1] = f
                    c = [c[0], c[1]-1]
    elif u[1] == c[1]:
                if c[0]-u[0] < 0:
                    for i in range(u[0]-c[0]-1):
                        c = [c[0]+1, c[1]]
                        f = b[c[0]-1]
                        f = f[: c[1]-1] + '|' + f[c[1]:]
                        b[c[0]-1] = f
                    c = [c[0]+1, c[1]]
                elif c[0]-u[0] > 0:
                    for i in range(c[0]-u[0]-1):
                        c = [c[0]-1, c[1]]
                        f = b[c[0]-1]
                        f = f[: c[1]-1] + '|' + f[c[1]:]
                        b[c[0]-1] = f
                    c = [c[0]-1, c[1]]
    elif u[0]-c[0] == u[1]-c[1]:
                if u[0]-c[0] > 0:
                    for i in range(u[0]-c[0]-1):
                        c = [c[0]+1, c[1]+1]
                        f = b[c[0]-1]
                        f = f[: c[1]-1] + '\\' + f[c[1]:]
                        b[c[0]-1] = f
                    c = [c[0]+1, c[1]+1]
                elif u[0]-c[0] < 0:
                    for i in range(c[0]-u[0]-1):
                        c = [c[0]-1, c[1]-1]
                        f = b[c[0]-1]
                        f = f[: c[1]-1] + '\\' + f[c[1]:]
                        b[c[0]-1] = f
                    c = [c[0]-1, c[1]-1]
    elif c[0]-u[0] == u[1]-c[1]:
                if u[0]-c[0] < 0:
                    for i in range(c[0]-u[0]-1):
                        c = [c[0]-1, c[1]+1]
                        f = b[c[0]-1]
                        f = f[: c[1]-1] + '/' + f[c[1]:]
                        b[c[0]-1] = f
                    c = [c[0]-1, c[1]+1]
                elif u[0]-c[0] > 0:
                    for i in range(u[0]-c[0]-1):
                        c = [c[0]+1, c[1]-1]
                        f = b[c[0]-1]
                        f = f[: c[1]-1] + '/' + f[c[1]:]
                        b[c[0]-1] = f
                    c = [c[0]+1, c[1]-1]

# Oliko ymmärrettävä?

def j(b, v, l):
    for u in range(len(b)):
        print(b[u])
    print("")
    if b[v][l]!="#":
        b[v] = b[v][: l] + '#' + b[v][l+1:]
    if b[v][l-1]== ".":
        b[v] = b[v][: l-1] + '#' + b[v][l:]
        j(b, v, l-1)
    if b[v+1][l]== ".":
        b[v+1] = b[v+1][: l] + '#' + b[v+1][l+1:]
        j(b, v+1, l)
    if b[v-1][l]== ".":
        b[v-1] = b[v-1][: l] + '#' + b[v-1][l+1:]
        j(b, v-1, l)
    if b[v][l+1]== ".":
        b[v] = b[v][: l+1] + '#' + b[v][l+2:]
        j(b, v, l+1)
        
     

g=[]


for i in range(len(b)):
    for y in range(len(b[i])-3):
        if b[i][y] != ".":
            if b[i][y] in ("|", "/", "\\"):
                if b[i][y+1] == ".":
                    j(b, i, y+1)
            break

for i in range(len(b)):
    for y in reversed(range(len(b[i]))):
        if b[i][y] != ".":
            if b[i][y] in ("|", "/", "\\"):
                if b[i][y-1] == ".":
                    j(b, i, y-1)
            break


for i in range(len(b[0])):
    for y in range(len(b)-3):
        if b[y][i] != ".":
            if b[y][i] in ("=", "/", "\\"):
                if b[y+1][i] == ".":
                    j(b, y+1, i)
            break

for i in range(len(b[0])):
    for y in reversed(range(len(b))):
        if b[y][i] != ".":
            if b[y][i] in ("=", "/", "\\"):
                if b[y-1][i] == ".":
                    j(b, y-1, i)
            break


for i in range(2):


    for i in range(len(b)):
        for z in range(len(b[i])):
            if b[i][z] == "#":
                

                if len(b[i])>z+3:
                    if b[i][z+1] in ("|", "=", "/", "\\"):
                            if b[i][z+2] == ".":
                                for p in range(len(b[i])-z-4):
                                    if b[i][z+p+3] == "*":
                                        break
                                    if b[i][z+p+2]==".":
                                        if b[i][z+p+3]in ("|", "=", "/", "\\"):
                                            if b[i][z+p+4]==".":
                                                    b[i] = b[i][: z+p+4] + '#' + b[i][z+p+5:]
                                                    j(b, i, z+p+4)
                                            break



    for i in range(len(b)):
        for z in range(len(b[i])):
            if b[i][z] == "#":
                

                if len(b[i])>z+3:
                    if b[i][z-1] in ("|", "=", "/", "\\"):
                            if b[i][z-2] == ".":
                                for p in range(z-2):
                                    if b[i][z-p-3] == "*":
                                        break
                                    if b[i][z-p-2]==".":
                                        if b[i][z-p-3]in ("|", "=", "/", "\\"):
                                            if b[i][z-p-4]==".":
                                                    b[i] = b[i][: z-p-4] + '#' + b[i][z-p-3:]
                                                    j(b, i, z-p-4)
                                            break

                                
    for i in range(len(b)):
        for z in range(len(b[i])):
            if b[i][z] == "#":
                

                if len(b)>i+3:
                    if b[i+1][z] in ("|", "=", "/", "\\"):
                            if b[i+2][z] == ".":
                                for p in range(len(b)-i-4):
                                    if b[i+p+3][z] == "*":
                                        break
                                    if b[i+p+2][z]==".":
                                        if b[i+p+3][z]in ("|", "=", "/", "\\"):
                                            if b[i+p+4][z]==".":
                                                    b[i+p+4] = b[i+p+4][: z] + '#' + b[i+p+4][z+1:]
                                                    j(b, i+p+4, z)
                                            break

    for i in range(len(b)):
        for z in range(len(b[i])):
            if b[i][z] == "#":
                
                
                if len(b)>i+3:
                    if b[i-1][z] in ("|", "=", "/", "\\"):
                            if b[i-2][z] == ".":
                                for p in range(i-2):
                                    if b[i-p-3][z] == "*":
                                        break
                                    if b[i-p-2][z]==".":
                                        if b[i-p-3][z]in ("|", "=", "/", "\\"):
                                            if b[i-p-4][z]==".":
                                                    b[i-p-4] = b[i-p-4][: z] + '#' + b[i-p-4][z+1:]
                                                    j(b, i-p-4, z)
                                            break

                                








for i in range(len(b)):
    print(b[i])

Test details

Test 1 (public)

Verdict: ACCEPTED

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

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

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

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

Test 2 (public)

Verdict: ACCEPTED

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

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

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

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

Test 3 (public)

Verdict: ACCEPTED

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

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

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

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

Test 4 (public)

Verdict: ACCEPTED

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

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

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

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

Test 5 (public)

Verdict: ACCEPTED

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

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

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

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

Test 6 (public)

Verdict: ACCEPTED

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

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

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

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

Test 7 (public)

Verdict: ACCEPTED

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

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

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

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

Test 8 (public)

Verdict: ACCEPTED

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

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

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

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

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 2, col 11: 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 2, col 6: expected '#', got '.'