개발자 톡
연습문제 톡
[HSAT 1회 정기 코딩 인증평가 기출] 안전운전을 도와줄 차세대 지능형 교통시스템
차세대 지능형 교통시스템 반례좀 부탁드립니다.
- 등록일
- 2021-10-14 21:17:57
- 조회수
- 1051
- 작성자
- marcha
import sys
# input
N, T = map(int, input().split())
signals = [[]*N for _ in range(N)]
for x in range(N):
for y in range(N):
signals[y].append(list(map(int, input().split())))
l = 'left'
r = 'right'
u = 'up'
d = 'down'
signal_def = [
[r,[u,r,d]],[u,[l,u,r]],[l,[u,l,d]],[d,[l,d,r]],
[r,[r,u]],[u,[u,l]],[l,[l,d]],[d,[d,r]],
[r,[r,d]],[u,[u,r]],[l,[l,u]],[d,[d,l]],
]
signal_map = {l:(-1,0), r:(1,0), u:(0,-1), d:(0,1)}
dir_map = {l:0, r:1, u:2, d:3}
cars = [[[0,0],u]]
mem = [[[[False]*4 for _ in range(4)] for _ in range(N)] for _ in range(N)] # pos_x, pos_y, time, direction
visited = set([])
for t in range(T+1):
for i in range(len(cars)):
isPassed = False
pos, direction = cars[i]
visited.add((pos[0],pos[1]))
if mem[pos[0]][pos[1]][t%4][dir_map[direction]] == True:
continue
mem[pos[0]][pos[1]][t%4][dir_map[direction]] = True
sig_idx = signals[pos[0]][pos[1]][t % 4] - 1
if direction == signal_def[sig_idx][0]:
for nxt_direction in signal_def[sig_idx][1]:
dx, dy = signal_map[nxt_direction]
next_x = pos[0] + dx
next_y = pos[1] + dy
if next_x >= 0 and next_x =0 and next_y
#[hsat_1회_정기_코딩_인증평가_기출]_안전운전을_도와줄_차세대_지능형_교통시스템
#python
#practice