문제 링크 : https://www.acmicpc.net/problem/1260풀이 과정DFS와 BFS를 구현하여 실행 과정을 출력했다.전체 코드# 1260 : DFS와 BFSimport sysfrom collections import dequeinput = sys.stdin.readlinen, m, v = map(int, input().rstrip().split())edges = [[] for _ in range(n+1)]for _ in range(m): a, b = map(int, input().rstrip().split()) edges[a].append(b) edges[b].append(a)for i in range(1, n+1): edges[i].sort()# DFSans ..
문제 링크 : https://www.acmicpc.net/problem/1074풀이 과정2xN 배열을 4등분 했을 때 어느 방향으로 갈지에 따라 다르게 탐색하는 재귀함수를 작성하여 풀이했다.전체 코드# 1074 : Zimport sysinput = sys.stdin.readlinedef func(size, start, sr, sc, er, ec): if size == 0: print(start) return # -- 4등분 했을 때 # 왼쪽 위에 있다면 if sr
문제 링크 : https://www.acmicpc.net/problem/1012풀이 과정BFS를 이용해 이웃한 배추 그룹의 개수를 센다.전체 코드# 1012 : 유기농 배추import sysfrom collections import dequeinput = sys.stdin.readlinet = int(input().rstrip())for _ in range(t): m, n, k = map(int, input().rstrip().split()) maps = [[False for _ in range(m)] for _ in range(n)] for _ in range(k): x, y = map(int, input().rstrip().split()) maps[y][x] ..
문제 링크 : https://www.acmicpc.net/problem/1003풀이 과정fibonacci(N) 이 0을 출력하는 횟수는, fibonacci(N-1) 에서 0을 출력하는 횟수 + fibonacci(N-2) 에서 0을 출력하는 횟수와 같다.이는 1을 출력할 때도 동일하다. 해당 점화식을 활용해 DP 테이블을 채워서 출력한다.전체 코드# 1003 : 피보나치 함수import sysinput = sys.stdin.readlinedp = [[0, 0] for _ in range(41)]dp[0] = [1, 0]dp[1] = [0, 1]for i in range(2, 41): dp[i] = [dp[i-2][0] + dp[i-1][0], dp[i-2][1] + dp[i-1][1]]t = int(inp..
문제 링크 : https://www.acmicpc.net/problem/11724풀이 과정BFS 를 이용해 연결되있는 그룹들의 개수를 셌다.전체 코드# 11724 : 연결 요소의 개수import sysfrom collections import dequeinput = sys.stdin.readlinen, m = map(int, input().rstrip().split())edges = [[] for _ in range(n+1)]for _ in range(m): u, v = map(int, input().rstrip().split()) edges[u].append(v) edges[v].append(u)visited = [False for _ in range(n+1)]cnt = 0for i i..
문제 링크 : https://www.acmicpc.net/problem/1927풀이 과정파이썬의 heapq 라이브러리를 이용해 풀이했다.전체 코드# 1927 : 최소 힙import sysimport heapqinput = sys.stdin.readlinen = int(input().rstrip())pq = []for _ in range(n): v = int(input().rstrip()) if v == 0: print(heapq.heappop(pq) if pq else 0) else: heapq.heappush(pq, v)
- Total
- Today
- Yesterday
- C++
- Sort
- Binary-Search
- java
- queue
- Python
- sparse_table
- math
- Prefix-Sum
- BFS
- number_theory
- lca
- backtracking
- kmp
- string
- PS
- ad_hoc
- lazy-propagation
- bruteforcing
- C
- DP
- 백준
- knapsack
- implementation
- Greedy
- segment-tree
- bitmask
- stack
- codeup
- BOJ
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
