목록Algorithms/Simulation (18)
from collections import deque N, L = map(int, input().split()) horizontal_street = [list(map(int, input().split())) for _ in range(N)] vertical_street = [[] for _ in range(N)] for i in range(N): for j in range(N): vertical_street[i].append(horizontal_street[j][i]) def pass_ok(street): temp = 0 start = 0 while start < N-1: if abs(street[start] - street[start+1]) == 2: return False # 오르막 설치 elif s..
from collections import deque n, m = map(int, input().split()) # 행(세로) / 열(가로) # position[2] = 방향 (0,1,2,3 / 북,동,남,서) y, x, direction = map(int, input().split()) map_list = [list(map(int, input().split())) for _ in range(n)] # 북 동 남 서 # 0 1 2 3 dirs = [(0,-1), (-1,0), (0,1), (1,0)] back = {0: (1,0), 1: (0,-1), 2: (-1,0), 3: (0,1)} def bfs(start, map_list): queue = deque() queue.append(start) # 청..
from collections import deque gear_list = [] # gear_list[0], gear_list[1], gear_list[2], gear_list[3] for _ in range(4): gear = ' '.join(input()) gear_list.append(deque(map(int, gear.split()))) k = int(input()) options = [] for _ in range(k): options.append(list(map(int, input().split()))) def rotate(gear_list, option): selection = option[0] direction = option[1] present_gear = gear_list[selecti..
1. 시작점 x, y 2. 방향 이동 1 (east), 2 (west), 3(north), 4(south) nx, ny 새로 정의 3. 지도 넘는 경우 분류 (지도 넘으면 그대로 있기, 지도 넘지 않는 경우 이동) 4. 이동 방향에 해당 하는 주사위로 주사위 위치 변경 동쪽: east, bottom, west, top = bottom, west, top, east 서쪽: top,south, bottom, north = west, bottom, east, top 북쪽: top, south, bottom, north = south, bottom, north, top 남쪽: top, south, bottom, north = north, top, south, bottom 5. 이동한 위치 값 분류 (0인 경우,..
from collections import Counter A = int(input()) B = int(input()) C = int(input()) res = A*B*C res = str(res) cnt = Counter(res) for i in range(0,10): i = str(i) print(cnt[i]) # Counter 사용법 익히기 -> var = Counter(list) -> 각 요소 개수 출력 ################## from collections import Counter A = int(input()) B = int(input()) C = int(input()) res = str(A*B*C) for i in range(0,10): i = str(i) print(res.count..