본문 바로가기

분류 전체보기

(402)
[백준 11409번] 열혈강호 6 (Python3) import sys from collections import * def input(): return [*map(int,sys.stdin.readline().split())] def SPFA(): DP = [1e9]*K; DP[0] = 0 parent = [0]*K dq = deque([0]); inq = [0]*K while dq: now = dq.popleft() inq[now] = 0 for next,w,c in graph[now]: if c-flow[now][next] and (w1:=DP[now]+w)
[백준 11408번] 열혈강호 5 (Python3) import sys from collections import * def input(): return [*map(int,sys.stdin.readline().split())] def SPFA(): DP = [1e9]*K; DP[0] = 0 parent = [0]*K dq = deque([0]); inq = [0]*K while dq: now = dq.popleft() inq[now] = 0 for next,w,c in graph[now]: if c-flow[now][next] and (w1:=DP[now]+w)
[백준 2316번] 도시 왕복하기 2 (Python3) import sys from collections import * def input(): return map(int,sys.stdin.readline().split()) def BFS(): visited = [-1]*N dq = deque([(1,0)]) while dq: now,last = dq.popleft() if visited[now]
[백준 11378번] 열혈강호 4 (Python3) import sys def input(): return [*map(int,sys.stdin.readline().split())] def DFS(i): if visited[i]: return 0 visited[i] = 1 for w in graph[i]: if work[w]
[백준 17412번] 도시 왕복하기 1 (Python3) import sys from collections import * def input(): return map(int,sys.stdin.readline().split()) def BFS(): f = 1e9; visited = [-1]*N dq = deque([(0,0)]) while dq: now,last = dq.popleft() if visited[now]
[백준 2934번] LRH 식물 (Python3) import sys input = sys.stdin.readline def update(v,a,b,s,e,x): if a==s and b==e: seg[x] += v return mid = (s+e)//2 if b mid: update(v,a,b,mid+1,e,x*2+1) else: update(v,a,mid,s,mid,x*2) update(v,mid+1,b,mid+1,e,x*2+1) def cal(n,s,e,x): if s==e: return seg[x] mid = (s+e)//2 if n
[백준 12844번] XOR (Python3) import sys input = sys.stdin.readline def make(s,e,x): if s==e: seg[x] = seq[s] else: mid = (s+e)//2 seg[x] = make(s,mid,x*2)^make(mid+1,e,x*2+1) return seg[x] def update(i,j,v,s,e,x): if (j-i+1)%2: seg[x] ^= v if (e-s+1)%2: seg[x] ^= lazy[x] if s!=e: lazy[x*2] ^= lazy[x]; lazy[x*2+1] ^= lazy[x] lazy[x] = 0 if i==s and j==e: if s!=e: lazy[x*2] ^= v; lazy[x*2+1] ^= v return seg[x] mid = (s+e)//2 ..
[백준 16903번] 수열과 쿼리 - 20 (Python3) import sys input = sys.stdin.readline def update(x,v): now = trie for i in reversed(range(30)): b = (x>>i)&1 if not now.get(b): now[b] = {} now = now[b] if not now.get(-1): now[-1] = 0 now[-1] += v def find(x): r = "" now = trie for i in reversed(range(30)): b = ((x>>i)&1)^1 if now.get(b) and now[b][-1]: r += "1" now = now[b] else: r += "0" now = now[b^1] return int(r,2) N = int(input()) trie = ..