본문 바로가기

전체 글

(54)
[삼성SW역량테스트] 마법사상어와 토네이도 (백준 20057)| Python3 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849import sysinput=sys.stdin.readline def get_move_order(n): orders=[] # (r,c,d) direction=[(0,-1),(1,0),(0,1),(-1,0)] r,c,d=n//2,n//2,0 for i in range(1,n): for _ in range(2): for j in range(i): mr,mc=r+direction[d%4][0], c+direction[d%4][1] orders.append((mr,mc,d%4)) r,c=mr,mc d+=1 for i in range(n-2,-1,-1): ..
[삼성SW역량테스트] 스타트 택시 (백준 19238)| Python3 모든 승객의 출발지는 다르지만, 목적지는 같을 수 있습니다 !! 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465import sysimport heapqfrom collections import dequeinput=sys.stdin.readline def get_shortest_path(map_of_passenger, arrive_flag=False, arrive_r=None, arrive_c=None): shortest_path=[]; count=number_of_passenger map_of_path=[[0]*n for _ in ran..
[삼성SW역량테스트] 청소년 상어 (백준 19236)| Python3 풀이) 문제에 쓰여진 대로 하되, 조건을 똑바로 읽자,,,! (상어는 빈 곳으로 움직일 수 없다든가...), 그리고 dfs 호출할 때 마다 deepcopy로 보내야한다. 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869import sysimport heapqfrom copy import deepcopyinput=sys.stdin.readline def fish_move(maps): direction=[(-1,0),(-1,-1),(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,1)] heap=make_heap(..