Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions wnsmir/κ΅¬ν˜„/λ“œλž˜κ³€μ»€λΈŒ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
N = int(input())
grid = [[0]*101 for _ in range(101)]

def rot90(p, pivot):
x, y = p
px, py = pivot
return (px - (y - py), py + (x - px))

def curve(last_gen, last_spot):
new_gen = last_gen[:]
for dot in reversed(last_gen[:-1]): # 쀑심 μ œμ™Έ μ—­μˆœμœΌλ‘œ
nx, ny = rot90(dot, last_spot)
if 0 <= nx <= 100 and 0 <= ny <= 100:
grid[ny][nx] = 1
new_gen.append((nx, ny))
return new_gen, new_gen[-1]

for _ in range(N):
x, y, d, g = map(int, input().split())

last_gen = [(x, y)]
grid[y][x] = 1

# 0μ„ΈλŒ€ λ§Œλ“€κΈ°
if d == 0:
last_spot = (x+1, y)
elif d == 1:
last_spot = (x, y-1)
elif d == 2:
last_spot = (x-1, y)
else:
last_spot = (x, y+1)

last_gen.append(last_spot)
lx, ly = last_spot
if 0 <= lx <= 100 and 0 <= ly <= 100:
grid[ly][lx] = 1

# g μ„ΈλŒ€μˆ˜λ§ŒνΌ
for _ in range(g):
last_gen, last_spot = curve(last_gen, last_spot)

# μ‚¬κ°ν˜• 개수
answer = 0
for y in range(100):
for x in range(100):
if grid[y][x] == 1 and grid[y][x+1] == 1 and grid[y+1][x] == 1 and grid[y+1][x+1] == 1:
answer += 1

print(answer)