일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- 나머지
- 안드로이드
- permutation
- 1260
- 홈화면
- Android
- 코테
- 6603
- itertools
- 뒤로가기
- 파이썬
- 1182
- Combination
- lcm
- 9095
- 코틀린
- 괄호
- 11053
- 백준
- 매일11시
- 최소공배수
- Python
- 11054
- Kotlin
- LCS
- 앱
- 11기
- 순열
- expo
- 11057
- Today
- Total
목록분류 전체보기 (181)
황소개발자
화이팅! n, k = map(int, input().split()) dist = [-1 for i in range(100001)] from collections import deque def bfs(v): q = deque() q.append(v) dist[v] = 0 while q: now = q.popleft() if now + 1 = 0 and dist[now - 1] == -1: q.append(now - 1) dist[now - 1] = dist[now] + 1 if now * 2
리스트에서 pop할 때, 시간복잡도는 O(n) 이다. 그러나 콜렉션에 디큐에서 pop의 시간복잡도는 O(1) 로 구현되어있다. import sys from collections import deque input = sys.stdin.readline dx = [1, -1, 0, 0] dy = [0, 0, 1, -1] w, h = map(int, input().split()) mat = [] for i in range(h): mat.append(list(map(int, input().split()))) q = deque() for i in range(h): for j in range(w): if mat[i][j] == 1: q.append([i, j]) def bfs(): global q while q: n..
import sys input = sys.stdin.readline h, w = map(int, input().split()) mat = [[] for i in range(h)] dx = [1, -1 , 0, 0] dy = [0, 0, 1, -1] for i in range(h): ss = input().strip() for s in ss: mat[i].append(int(s)) def bfs(y, x): q = [[y, x]] while q: now = q.pop(0) for i in range(4): ny = now[0] + dy[i] nx = now[1] + dx[i] if 0
import sys input = sys.stdin.readline dx = [1, -1, 0, 0, 1, 1, -1, -1] dy = [0, 0, 1, -1, 1, -1, 1, -1] def bfs(y, x, count): q = [[y, x]] while q: now = q.pop(0) for i in range(8): ny = now[0] + dy[i] nx = now[1] + dx[i] if 0
import sys input = sys.stdin.readline dx = [1, -1, 0, 0] dy = [0, 0, 1, -1] def bfs(y, x, count, total): q = [[y, x]] mat[y][x] = count total += 1 while q: now = q.pop(0) for i in range(4): ny = now[0] + dy[i] nx = now[1] + dx[i] if 0
import sys input = sys.stdin.readline def bfs_binary(v, visited, color): q = [v] visited[v] = True color[v] = 1 while q: now = q.pop(0) for nxt in adj_lst[now]: if not visited[nxt]: q.append(nxt) color[nxt] = 3 - color[now] visited[nxt] = True else: if color[now] == color[nxt]: return False return True t = int(input()) for i in range(t): n, m = map(int, input().split()) adj_lst = [[] for _ in ra..
import sys input = sys.stdin.readline n, m, v = map(int, input().split()) adj_lst = [[] for i in range(n + 1)] visited = [False for i in range(n + 1)] for i in range(m): a, b = map(int, input().split()) adj_lst[a].append(b) adj_lst[b].append(a) for i in range(n): adj_lst[i].sort() def dfs(v, lst): lst += [v] for nxt in adj_lst[v]: if nxt not in lst: dfs(nxt, lst) return lst def bfs(v): lst = [] ..
import sys input = sys.stdin.readline n, m = map(int, input().split()) adj_lst = [[] for i in range(n)] for i in range(m): a, b = map(int, input().split()) adj_lst[a].append(b) adj_lst[b].append(a) visited = [False for i in range(n)] def dfs(v, depth): global ans visited[v] = True if depth >= 4: ans = True return for nxt in adj_lst[v]: if not visited[nxt]: dfs(nxt, depth + 1) visited[nxt] = Fals..