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

날짜 : 2023. 10. 18 사용 언어 : python 문제 코드 import sys import copy def dust(): # 미세먼지 확장 tmp = copy.deepcopy(graph) for x in range(r): for y in range(c): if tmp[x][y] > 0: cnt = 0 # 확산개수 for i in range(4): nx, ny = x + dx[i], y + dy[i] if nx in range(r) and ny in range(c): # 범위 포함 if graph[nx][ny] != -1: # 청정기가 아닌 경우 cnt += 1 graph[nx][ny] += int(tmp[x][y] // 5) graph[x][y] -= int(tmp[x][y] // 5) * c..

날짜 : 2023. 10. 14 사용 언어 : python 문제 코드 def solution(fees, records): check = dict() # 입차, 출차 체크 parktime = dict() # 차량별 주차시간 res = dict() for i in range(len(records)): tmp, num, inout = records[i].split() hh, mm = tmp.split(":") time = int(hh) * 60 + int(mm) records[i] = [time, num, inout] if num not in check: check[num] = -1 parktime[num] = 0 res[num] = 0 for i in range(len(records)): time, num,..

날짜 : 2023. 10. 14 사용 언어 : python 문제 코드 오답코드 def solution(booktime): def timediff(before, after): hour = int(after[0]) - int(before[0]) minute = int(after[1]) - int(before[1]) if minute < 0: hour -= 1 minute += 60 return hour * 60 + minute time = list() for start, end in booktime: start = list(start.split(":")) end = list(end.split(":")) time.append([int(start[0]), int(start[1]), timediff(start, ..

날짜 : 2023. 10. 14 사용 언어 : python 문제 코드 def solution(picks, minerals): check = list() # 우선순위 리스트 pick = picks[0] + picks[1] + picks[2] if len(minerals) > pick * 5: # 현재 있는 곡괭이로 캘 수 없는 광물들 생략 minerals = minerals[:pick * 5] for i in range(0, len(minerals), 5): tmp = 0 for j in range(i, i + 5): if j not in range(len(minerals)): break if minerals[j] == "diamond": tmp += 25 elif minerals[j] == "iron":..

날짜 : 2023. 10. 12 사용 언어 : python 문제 코드 def solution(plans): def time_cal(a, b): # b와 a 시간계산(분) hour = (b[0] - a[0]) minute = (b[1] - a[1]) if minute < 0: hour -= 1 minute += 60 return hour * 60 + minute res = list() arr = list() for sub, time, cost in plans: # 전처리 h, m = time.split(":") arr.append([sub, int(h), int(m), int(cost)]) arr.sort(key = lambda x : (x[1], x[2])) # 시간 순으로 정렬 rest = list()..

날짜 : 2023. 10. 04 사용 언어 : python 문제 코드 def solution(graph): dist = len(graph) def check(r, c, length): # print(r, c, length) if length == 0: return flag = graph[r][c] # 기준값 저장 for i in range(r, r + length): for j in range(c, c + length): if flag != graph[i][j]: # 압축 불가능 -> 재귀 check(r, c, length // 2) check(r, c + length // 2, length // 2) check(r + length // 2, c, length // 2) check(r + length /..

날짜 : 2023. 10. 03 사용 언어 : python 문제 코드 def solution(n): tri = [[-1] * 1001 for _ in range(1001)] for i in range(n): for j in range(i + 1): tri[i][j] = 0 r, c, d = 0, 0, 0 dx = [1, 0, -1] dy = [0, 1, -1] tri[r][c] = 1 # 시작점 cnt = 1 while cnt < (n * (n + 1) // 2): cnt += 1 # 카운트 증가 nx = r + dx[d] # 다음 좌표 ny = c + dy[d] if tri[nx][ny] != 0: # 이미 접근했거나 범위를 이탈 d = (d + 1) % 3 # 방향 전환 nx = r + dx[d] #..

날짜 : 2023. 09. 26 사용 언어 : python 문제 코드 시간초과 코드 def solution(n): nums = [1, 2, 4] res = [1] cnt = 0 def carry(idx): if idx == -1: res.insert(0, 1) return if res[idx] == 1: res[idx] = 2 elif res[idx] == 2: res[idx] = 4 else: res[idx] = 1 carry(idx-1) return while True: cnt += 1 if cnt == n: break idx = len(res) - 1 if res[idx] == 1: res[idx] = 2 continue elif res[idx] == 2: res[idx] = 4 continue e..