-
[백준 문제풀이] 얼렁뚱땅 17114 미세먼지 안녕! 풀이얼렁뚱땅 백준 문제풀이 2022. 10. 10. 19:26
https://www.acmicpc.net/problem/17144
17144번: 미세먼지 안녕!
미세먼지를 제거하기 위해 구사과는 공기청정기를 설치하려고 한다. 공기청정기의 성능을 테스트하기 위해 구사과는 집을 크기가 R×C인 격자판으로 나타냈고, 1×1 크기의 칸으로 나눴다. 구사
www.acmicpc.net
제발제발제발 이정도만 나오게해주세요 제발요제발요 이렇게 빌게요 제발요
from copy import deepcopy r, c, t = map(int,input().split()) arr= [] up_cleaner = [] down_cleaner = [] sign = 0 for i in range(r) : temp = list(map(int,input().split())) arr.append(temp) if -1 in temp and sign == 0 : up_cleaner = [i,0] down_cleaner = [i+1,0] sign = 1 dx = [0, 0, -1, 1] dy = [1, -1, 0, 0] for _ in range(t) : # 미세먼지가 확산된다. 미세먼지가 있는 칸에서 동시에 일어난다 -> 중간에 합쳐지고 이런거 계산 안되게 따로 써야함 temp = [[0]*c for _ in range(r)] for i in range(r) : for j in range(c) : if arr[i][j] >= 1 : count = 0 for k in range(len(dx)) : nx = i + dx[k] ny = j + dy[k] wow = arr[i][j]//5 if 0<=nx<r and 0<=ny<c and [nx,ny] != up_cleaner and [nx,ny] != down_cleaner: count += 1 temp[nx][ny] += arr[i][j]//5 temp[i][j] += arr[i][j] - wow * count new_temp = [[0]* c for _ in range(r)] for i in range(r) : if i == up_cleaner[0] or i == down_cleaner[0] : new_temp[i] = [-1, 0] + list(temp[i][1:c-1]) elif i == 0 : new_temp[i] = list(temp[i][1:]) + [temp[i+1][c-1]] elif i == r-1 : new_temp[i] = list(temp[i][1:]) + [temp[i-1][c-1]] # i는 1부터 들어옴 elif i < up_cleaner[0] : new_temp[i] = [temp[i-1][0]]+list(temp[i][1:c-1])+ [temp[i+1][c-1]] elif i > down_cleaner[0] : new_temp[i] = [temp[i+1][0]] + list(temp[i][1:c-1]) + [temp[i-1][c-1]] arr = deepcopy(new_temp) real_sum = 0 for i in range(r) : if i == up_cleaner[0] or i == down_cleaner[0] : t = sum(arr[i]) real_sum += (t+1) else : real_sum += sum(arr[i]) print(real_sum)
'얼렁뚱땅 백준 문제풀이' 카테고리의 다른 글
[백준 문제풀이] 얼렁뚱땅 14890 경사로 풀이 (0) 2022.10.12 [백준 문제풀이] 얼렁뚱땅 14499 주사위 굴리기 풀이 (0) 2022.10.11 [백준 문제풀이] 얼렁뚱땅 1890 점프 풀이 (0) 2022.10.07 [백준 문제풀이] 얼렁뚱땅 2206 벽 부수고 이동하기 풀이 (0) 2022.10.07 [백준 문제풀이] 얼렁뚱땅 13975 파일합치기3 풀이 (0) 2022.10.07