N = int(input()) def bubble(arr,tc): global score all_row = set(range(6)) remove_arr = set() empty_arr = set() for row in range(5,-1,-1): if sum(arr[row]) == 4: remove_arr.add(row) elif not sum(arr[row]): empty_arr.add(row) remain_row = sorted(list(all_row - remove_arr - empty_arr)) temp = [] while len(remain_row) > 4: remain_row.pop() for _ in range(6-len(remain_row)): temp.append([0]*4) for row in remain_row: temp.append(arr[row][:]) score += len(remove_arr) return temp def move(arr,block_type,x,y,tc): global score if block_type == 1: for row in range(6): if arr[row][y]: arr[row-1][y] = 1 break else: arr[row][y] = 1 elif block_type == 2: for row in range(6): if arr[row][y] or arr[row][y+1]: arr[row-1][y] = 1 arr[row-1][y+1] = 1 break else: arr[row][y] = 1 arr[row][y+1] = 1 else: for row in range(5): if arr[row][y] or arr[row+1][y]: arr[row][y] = 1 arr[row-1][y] = 1 break else: arr[row][y] = 1 arr[row+1][y] = 1 return bubble(arr,tc) blue_arr = [[0]*4 for _ in range(6)] green_arr = [[0]*4 for _ in range(6)] score = 0 for tc in range(N): # 1번 1칸 2번 가로 2칸 3번 세로 2칸 block_type,x,y = map(int,input().split()) green_arr = move(green_arr,block_type,x,y,tc) if block_type == 2: block_type = 3 elif block_type == 3: block_type = 2 blue_arr = move(blue_arr,block_type,y,x,tc) print(score) total_block = sum(map(sum,green_arr)) + sum(map(sum,blue_arr)) print(total_block)
'알고리즘 > 백준_복기_미완료' 카테고리의 다른 글
[BOJ/백준] 20119 클레어와 물약 (0) | 2021.05.07 |
---|---|
[BOJ/백준] 20114 미아노트 (0) | 2021.05.07 |
[BOJ/백준] 20058 마법사 상어와 파이어스톰 (0) | 2021.05.07 |
[BOJ/백준] 19598 최소 회의실 개수 (0) | 2021.05.07 |
[BOJ/백준] 9370 미확인 도착지 (0) | 2021.05.07 |