[파이썬] 백준 뱀 문제 3190
https://www.acmicpc.net/problem/3190from collections import dequea,b = 0,0d= 0mi = 0n = int(input())k = int(input())group = set()for _ in range(k): x,y = map(int,input().split()) group.add((x-1,y-1)) L = int(input())X = []C = []for i in range(L): x,c = input().split() X.append(int(x)) C.append(c) turns = dict(zip(X, C)) dx = [0,1,0,-1]dy = [1,0,-1,0]def dir(d): dl = (d..
2025. 4. 20.
[파이썬] 백준 로봇청소기 문제 코드 정리.
https://www.acmicpc.net/problem/14503from collections import dequen,m = map(int,input().split())r,c,d=map(int,input().split())graph = []for _ in range(n): graph.append(list(map(int,input().split())))#북 동 남 서 cx = [-1, 0, 1, 0] cy= [0, 1, 0, -1]def turn_left(d): #방향 계산하는 일반 함수. return (d + 3) % 4 #하나의 청소기가 움직이는 것이므로 deque는 필요없음def move(r, c, d): count = 0 #청소한 갯수를 세어야하므로. while True: if g..
2025. 4. 7.
[파이썬]list(input()), list(map(int,input().split())) 차이
list(input()) : 문자열 한 글자씩 분해해서 저장해버리게 된다.예를 들어, 입력으로 1 0 0 이라고 썼다고 해본다.input() → "1 0 0"list(input()) → ['1', ' ', '0', ' ', '0'] ← 공백도 문자로 들어가게 된다.map(int, input().split()) → [1, 0, 0] ← 숫자만 리스트에 들어가게 된다. ex) graph = []graph.append(list(map(int,input().split())))
2025. 4. 7.