일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 시뮬레이션
- 트리
- 자료구조
- 분할정복
- 해시
- 그래프 이론
- 크루스칼
- 그래프 탐색
- 다익스트라
- 서브쿼리
- 투포인터
- BFS
- 구현
- DP
- 백트래킹
- 그리디
- GROUP BY
- 수학
- 누적합
- 브루트포스
- join
- 다시
- DFS
- 재귀
- 다이나믹프로그래밍
- 플로이드-워셜
- 에라토스테네스의 체
- MST
- 다이나믹 프로그래밍
- 우선순위큐
- Today
- Total
목록전체 글 (373)
기록하고 까먹지 말기

날짜 : 2023. 09. 03 사용 언어 : python 문제 코드 import sys n, m = map(int, sys.stdin.readline().split()) nums = list(map(int, sys.stdin.readline().split())) nums.sort() res = list() visited = [False] * n def bt(depth): if depth == m: print(*res) return for i in range(n): if not visited[i]: visited[i] = True res.append(nums[i]) bt(depth + 1) res.pop() visited[i] = False bt(0) 풀이 - 일반적인 백트래킹 방식으로 풀이한다 알게된 ..

날짜 : 2023. 08. 31 사용 언어 : python 문제 코드 import sys n, m = map(int, sys.stdin.readline().split()) nums = list(map(int, sys.stdin.readline().split())) nums.sort() res = list() visited = [False] * n def bt(depth): if depth == m: print(*res) return prev = 0 for i in range(n): if not visited[i] and prev != nums[i]: prev = nums[i] # 수열의 최신 원소 visited[i] = True # 방문처리 res.append(prev) bt(depth + 1) visi..

날짜 : 2023. 08. 07 사용 언어 : python 문제 코드 import sys n = int(sys.stdin.readline()) a = list(map(int, sys.stdin.readline().split())) res = [0] * n res[a[0]] = 1 for i in range(2, n+1): cnt = 0 # 자기보다 큰 사람의 수 idx = 0 # 서있는 위치 while True: if res[idx] == 0: if a[i-1] == cnt: res[idx] = i break else: idx += 1 cnt += 1 else: idx += 1 # print(*res) print(*res) 풀이 - 키가 1인 경우에는 무조건 본인보다 큰 사람이 없기 때문에 디폴트로 값을..

날짜 : 2023. 07. 27 사용 언어 : python 문제 코드 import sys n = int(sys.stdin.readline()) a = list() for _ in range(n): a.append(int(sys.stdin.readline())) t = int(round(n * 0.15 + 0.0000001)) if n == 0: print(0) exit(0) a.sort() a = a[t:n-t] s = 0 for i in a: s += i # print(a) print(int(round(s / len(a)+0.0000001))) 풀이 - 문제대로 n값이 0이 아닐 때 0.15를 곱해서 생략할 개수를 구한다. - 숫자 리스트를 정렬 후 값들을 생략한 다음 그 수들의 평균을 구하여 출력한다..

날짜 : 2023. 07. 25 사용 언어 : python 문제 코드 import sys from collections import deque def bfs(r, c): queue = deque() queue.append([r, c]) dx = [0, 0, 1, -1] dy = [1, -1, 0, 0] visited[r][c] = True cnt = 0 while queue: x, y = queue.popleft() for i in range(4): nx = x + dx[i] ny = y + dy[i] if nx in range(n) and ny in range(m) and not visited[nx][ny] and graph[nx][ny] != 'X': visited[nx][ny] = True queu..

날짜 : 2023. 07. 24 사용 언어 : python 문제 코드 import sys n = int(sys.stdin.readline()) tower = list(map(int, sys.stdin.readline().split())) stack = list() stack.append((-1, -1)) res = [0] * n # 현재 높이가 스택의 top보다 높다면 pop(반복), 낮으면 해당 인덱스 저장 for i in range(n): while stack: if tower[i] > stack[-1][0]: stack.pop() else: break if not stack: res[i] = 0 else: res[i] = stack[-1][1] stack.append((tower[i], i+1)) ..

날짜 : 2023. 07. 17 사용 언어 : python 문제 코드 import sys dx = [[0, 0, 0, 0], [0, 1, 2, 3], [0, 0, 1, 1], [0, 1, 2, 2], [0, 0, 0, 1], [0, 1, 1, 1], [0, 0, 1, 2], [0, 1, 2, 2], [0, 1, 1, 1], [0, 0, 0, 1], [0, 0, 1, 2], [0, 1, 1, 2], [0, 0, 1, 1], [0, 1, 1, 2], [0, 0, 1, 1], [0, 1, 1, 2], [0, 0, 0, 1], [0, 1, 1, 2], [0, 1, 1, 1]] dy = [[0, 1, 2, 3], [0, 0, 0, 0], [0, 1, 0, 1], [0, 0, 0, 1], [0, 1, 2, 0], ..

날짜 : 2023. 07. 15 사용 언어 : python 문제 코드 import sys from collections import deque def bfs(r, c): queue = deque() queue.append([r, c]) dx = [0, 0, 1, -1] dy = [1, -1, 0, 0] while queue: x, y = queue.popleft() for i in range(4): nx = x + dx[i] ny = y + dy[i] if nx in range(n) and ny in range(m) and not visited[nx][ny] and graph[nx][ny] == 1: visited[nx][ny] = True # 방문처리 graph[nx][ny] = graph[x][y] ..