목록python (182)
rose_brown
1. 문제https://school.programmers.co.kr/learn/courses/30/lessons/17678 2. 코드python 1def solution(n, t, m, timetable): crew = sorted([int(h) * 60 + int(m) for h, m in (time.split(":") for time in timetable)]) bus = 9 * 60 idx = 0 for i in range(n): count = 0 while idx 풀이timetable에 있는 값을 “분” 으로 변경첫차는 09:00이니까 분으로 변경하여 저장운행 횟수 만큼현재 위치 crew의 현재 시간 ≤ 시작시간 ⇒ 현재 승객이 ..

1. 문제https://www.acmicpc.net/problem/9466 2. 코드python 1import sysinput = sys.stdin.readlinesys.setrecursionlimit(10**6)t = int(input())for _ in range(t): n = int(input()) arrs = list(map(int, input().split())) arrs.insert(0, 0) visited = [False] * (n + 1) finished = [False] * (n + 1) count = 0 def dfs(current): global count visited[current] = True next_n..

1. 문제https://www.acmicpc.net/problem/15685 2. 코드python 1import sysinput = sys.stdin.readlinen = int(input())path = [(1, 0), (0, -1), (-1, 0), (0, 1)]board = [[0] * 101 for _ in range(101)]for _ in range(n): x, y, d, g = map(int, input().split()) board[x][y] = 1 curve = [d] for _ in range(g): for i in range(len(curve)-1, -1, -1): curve.append((curve[i]+1) % 4) cx,..
1. 문제https://school.programmers.co.kr/learn/courses/30/lessons/42628 2. 코드python 1import heapqdef solution(operations): q = [] # 양수 rq = [] # 음수 for operation in operations: alpha, num = operation.split() num = int(num) if alpha == "I": heapq.heappush(q, num) heapq.heappush(rq, -num) elif alpha == "D": if n..

1. 문제https://www.acmicpc.net/problem/15686 2. 코드python 1import sysinput = sys.stdin.readlinefrom itertools import combinationsn, m = map(int, input().split())graph = [list(map(int, input().split())) for _ in range(n)]house = []chicken = []for i in range(n): for j in range(n): if graph[i][j] == 1: house.append((i, j)) elif graph[i][j] == 2: chicken.append((i..

1. 문제https://www.acmicpc.net/problem/17135 2. 코드python 1import sysfrom itertools import combinationsfrom collections import dequeinput = sys.stdin.readlinen, m, d = map(int, input().split())graph = [list(map(int, input().split())) for _ in range(n)]archers = list(combinations(range(m), 3))path = [(0, -1), (-1, 0), (0, 1)]def bfs(row, col, temp_map): visited = [[False] * m for _ in range(n)] ..
1. 문제https://school.programmers.co.kr/learn/courses/30/lessons/12905 2. 코드python 1def solution(board): answer = max(max(row) for row in board) for row in range(1, len(board)): for col in range(1, len(board[0])): if board[row][col] == 1 : board[row][col] = min(board[row-1][col], board[row][col-1], board[row-1][col-1]) + 1 ..
1. 문제https://school.programmers.co.kr/learn/courses/30/lessons/60062 2. 코드python 1from itertools import permutationsdef solution(n, weak, dist): length = len(weak) extended_weak = weak + [w + n for w in weak] answer = len(dist) + 1 for start in range(length): for friends in permutations(dist): count = 1 position = extended_weak[start] + friends[0] ..

1. 문제https://www.acmicpc.net/problem/14502 2. 코드python 1import sysimport copyfrom collections import dequefrom itertools import combinationsinput = sys.stdin.readlinen, m = map(int, input().split())graph = [list(map(int, input().split()))for _ in range(n)]path = [(-1, 0), (1, 0), (0, 1),(0, -1)]comb = []for i in range(n): for j in range(m): if graph[i][j] == 0: comb.append((..

1. 문제https://www.acmicpc.net/problem/16918 2. 코드python 1import sysinput = sys.stdin.readliner, c, n = map(int, input().split())board = [list(input().strip()) for _ in range(r)]path = [(-1, 0), (1, 0),(0, -1),(0, 1)]def bomb(board): to_bomb = set() for i in range(r): for j in range(c): if board[i][j] == 'O': to_bomb.add((i, j)) for dx, dy in p..