From 3fa14c1b7a18a625448c7e5f28268f769c9826bf Mon Sep 17 00:00:00 2001 From: leejw-lu Date: Sat, 30 Dec 2023 00:19:22 +0900 Subject: [PATCH] =?UTF-8?q?#17=2017144=EB=B2=88=20=EB=AF=B8=EC=84=B8?= =?UTF-8?q?=EB=A8=BC=EC=A7=80=20=EC=95=88=EB=85=95!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\247\200 \354\225\210\353\205\225!.py" | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 "\354\213\234\353\256\254\353\240\210\354\235\264\354\205\230/17144_\353\257\270\354\204\270\353\250\274\354\247\200 \354\225\210\353\205\225!.py" diff --git "a/\354\213\234\353\256\254\353\240\210\354\235\264\354\205\230/17144_\353\257\270\354\204\270\353\250\274\354\247\200 \354\225\210\353\205\225!.py" "b/\354\213\234\353\256\254\353\240\210\354\235\264\354\205\230/17144_\353\257\270\354\204\270\353\250\274\354\247\200 \354\225\210\353\205\225!.py" new file mode 100644 index 0000000..23c99f9 --- /dev/null +++ "b/\354\213\234\353\256\254\353\240\210\354\235\264\354\205\230/17144_\353\257\270\354\204\270\353\250\274\354\247\200 \354\225\210\353\205\225!.py" @@ -0,0 +1,85 @@ +import sys +read=sys.stdin.readline + +dx = [0,-1,0,1] #동북서남 (x,y 방향 주의!!!!) +dy = [1,0,-1,0] +airCleaner=[] +result=0 + +#r과 c 범위가 매우 작기 때문에 미리 먼지 위치 append 안해도 된다. +#1. 미세먼지 확산 -> "동시성" +def spread(): + temp=[[0]*c for _ in range(r)] + for i in range(r): + for j in range(c): + if graph[i][j]!=0 and graph[i][j]!=-1: + dust=0 + for k in range(4): + nx=i+dx[k] + ny=j+dy[k] + if 0<=nx북->서->남 +def clean_up(): + d=0 #동 부터 시작 + before=0 + x,y=airCleaner[0],1 #로봇 다음칸 + + while True: + nx=x+dx[d] + ny=y+dy[d] + if nx<0 or nx>=r or ny<0 or ny>=c: + d=(d+1)%4 + continue + if x==airCleaner[0] and y==0: + break + + graph[x][y],before = before,graph[x][y] + x,y=nx,ny + +#3. 공기청정기 아래쪽: 동->남->서->북 +def clean_down(): + d=0 #동 부터 시작 + before=0 + x,y=airCleaner[1],1 #로봇 다음칸 + + while True: + nx=x+dx[d] + ny=y+dy[d] + if nx<0 or nx>=r or ny<0 or ny>=c: + d=(d-1)%4 + continue + if x==airCleaner[1] and y==0: + break + + graph[x][y],before = before,graph[x][y] + x,y=nx,ny + +#___________________main +r,c,t=map(int,read().split()) +graph=[list(map(int,read().split())) for _ in range(r)] + +#공기청정기 위치 찾기 +for i in range(r): + if graph[i][0]==-1: + airCleaner.append(i) + +for _ in range(t): + spread() + clean_up() + clean_down() + +#미세먼지 출력 +for i in range(r): + for j in range(c): + if graph[i][j]>0: + result+=graph[i][j] +print(result) +