Skip to content

Commit caca4e9

Browse files
ing-eokingbugs-bot
authored andcommitted
๐Ÿœ Study: ํ–‰๋ ฌ ํ…Œ๋‘๋ฆฌ ํšŒ์ „ํ•˜๊ธฐ (#88)
1 parent b9c15a0 commit caca4e9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def solution(rows, columns, queries):
2+
answer = []
3+
m = [[i * columns + j + 1 for j in range(columns)] for i in range(rows)]
4+
for x1, y1, x2, y2 in queries:
5+
x1, y1, x2, y2 = x1-1, y1-1, x2-1, y2-1
6+
p = ([(x1, y) for y in range(y1, y2)] +
7+
[(x, y2) for x in range(x1, x2)] +
8+
[(x2, y) for y in range(y2, y1, -1)] +
9+
[(x, y1) for x in range(x2, x1, -1)])
10+
prev = m[p[-1][0]][p[-1][1]]
11+
pv = [m[x][y] for x, y in p]
12+
mv = min(pv + [prev])
13+
for (x, y), val in zip(p, [prev] + pv[:-1]):
14+
m[x][y] = val
15+
answer.append(mv)
16+
return answer

0 commit comments

Comments
ย (0)