Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

22.01.20 - 오늘의 PS #97

Merged
merged 2 commits into from Jan 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
59 changes: 59 additions & 0 deletions 1_PS/2_baekjoon_online_judge/3_Gold/5/14503.py
@@ -0,0 +1,59 @@
"""
Date : 2022.01.20
Update : 2022.01.20
Source : 14503.py
Purpose :
url : https://www.acmicpc.net/problem/14503
Author : 김학진 (mildsalmon)
Email : mildsalmon@gamil.com
"""

def move(graph, x, y, d, is_wall):
global clean_area
ds = ((-1, 0), (0, 1), (1, 0), (0, -1))

while not is_wall:
if graph[x][y] != 2:
clean_area += 1
graph[x][y] = 2

count = 0

for i in range(4):
d = (d - 1) % 4

dx = x + ds[d][0]
dy = y + ds[d][1]

if graph[dx][dy] != 1:
if graph[dx][dy] == 0:
x, y = dx, dy
break

count += 1

if count == 4:
dx = x - ds[d][0]
dy = y - ds[d][1]

if graph[dx][dy] == 1:
print(clean_area)
is_wall = True
else:
x, y = dx, dy


if __name__ == "__main__":
n, m = list(map(int, input().split()))
r, c, d = list(map(int, input().split()))

graph = []

for _ in range(n):
temp = list(map(int, input().split()))
graph.append(temp)

clean_area = 0

move(graph, r, c, d, False)