본문 바로가기

분류 전체보기

(402)
백준 다이아몬드 달성 짧은 후기 백준을 시작한지 대략 반년만에 드디어 다이아몬드를 달성하였다. 플래티넘 드디어 백준 플래티넘 달성! (tistory.com) 달성 이후, 무려 5달이 넘게 지나고 나서야 달성할 수 있었다. 사실 스트릭이나 AC레이팅 그래프를 보면 알 수 있듯이 어느 시점 이후로는 PS에 대한 흥미가 약간 떨어진 것이 사실이다. 그래서인지 언레이팅에서 플래티넘을 찍은 기간보다 플래티넘에서 다이아를 찍은 기간이 거의 4배는 더 오래 걸렸다. 그래도 어쨌든 처음 백준을 시작할 때 목표아닌 목표로 잡았던 다이아몬드를 대략 반년간 달려온 결과 달성하였으니 어느정도 만족스럽다. 이제는 목표는 이뤘으니 앞으로의 방향성을 결정해야 할 시기인 것 같다. 사실 다이아까지 오면서 이미 파이썬의 한계를 뼈저리게 느끼고 있는 중이라서... 만..
[백준 7577번] 탐사 (Python) import sys,collections input = lambda: [*map(int,sys.stdin.readline().split())] def SPFA(): inq = [[0]*(K+1) for i in range(K+1)] while dq: a,b = dq.popleft() inq[a][b] = 0; q = [] if upper[a][b](s:=upper[i][b]-lower[a][b]): upper[i][a] = s q.append((i,a)) if lower[i][a](s:=upper[i][a]+upper[a][b]): upper[i][b] = s q.append((i,b)) if lower[i][b](s:=upper[a][b]-lower[i][b]): upper[a][i] = s q.app..
[백준 3654번] L퍼즐 (Python) import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) d = [1,0,-1,0] def DFS(now): global id,S ID[now] = nowid = id stack.append(now) for next in graph[now]: if scc[next]: continue if not ID[next]: id += 1 DFS(next) ID[now] = min(ID[now],ID[next]) if ID[now]==nowid: S += 1 while 1: x = stack.pop() scc[x] = S if x==now: return def check(): if sum(board[i].count("W") for i in range(N)..
[백준 13557번] 수열과 쿼리 10 (Python) import sys input = sys.stdin.readline def make(s,e,x): if s==e: seg[0][x]=seg[1][x]=prefix[s] seg[2][x]=data[s-1] return mid = (s+e)//2 make(s,mid,x*2); make(mid+1,e,x*2+1) seg[0][x] = min(seg[0][x*2],seg[0][x*2+1]) seg[1][x] = max(seg[1][x*2],seg[1][x*2+1]) seg[2][x] = max(seg[2][x*2],seg[2][x*2+1],seg[1][x*2+1]-seg[0][x*2]) def minmax(i,j,s,e,x,m): if i==s and j==e: return seg[m][x] mid = (s+e..
[백준 14504번] 수열과 쿼리 18 (Python) import sys input = sys.stdin.readline def update(n,i,v): while i
[백준 1031번] 스타 대결 (Python) from collections import * def BFS(): dq = deque([0]); parent = [-1]*K while dq: now = dq.popleft() for next in adj[now]: if parent[next]
[백준 2570번] 비숍2 (Python) def DFS(i): if visited[i]: return 0 visited[i] = 1 for j in graph[i]: if not match[j]: match[j] = i return 1 for j in graph[i]: if DFS(match[j]): match[j] = i return 1 return 0 N = int(input()) board = [[0]*N for i in range(N)] for y,x in [map(int,input().split()) for i in range(int(input()))]: board[y-1][x-1] = -1 R = 0 for k in range(N*2): R += 1 for y in range(N): if N>y>=0 and N>k-y>=0: if b..
[백준 2519번] 막대기 (Python) import sys sys.setrecursionlimit(10**4) input = lambda : [*map(int,sys.stdin.readline().split())] def ccw(x1,y1,x2,y2,x,y): return (x2-x1)*(y-y1)-(y2-y1)*(x-x1) def crossed(x1,y1,x2,y2,x3,y3,x4,y4): return ccw(x1,y1,x2,y2,x3,y3)*ccw(x1,y1,x2,y2,x4,y4)