/ https://42jerrykim.github.io/ _index.md
Avatar

42JerryKim

42는 'The Hitchhiker's Guide to the Galaxy'라는 SF 소설에서 삶, 우주, 그리고 모든 것에 대한 궁극적인 질문에 대한 해답이다.

  1. Home
  2. Collections
  3. Search
  4. Categories
  5. Tags
  6. Archives
    1. Dark Mode

Categories

Algorithm BOJ Vocabulary Graph English Movie Math CSharp Data Structures Geometry

Tags

Implementation C++ Algorithm BOJ 백준 알고리즘 Cpp 구현 시간복잡도 Time Complexity Space Complexity 공간복잡도 Competitive Programming Optimization 최적화 Edge Cases 코너 케이스 경쟁프로그래밍 정당성 증명 Proof of Correctness

Archives

2025 412
2024 178
2023 24
2022 82
2021 25
More
Featured image of post [Algorithm] C++ 백준 10050번: 블록
Algorithm BOJ Constructive Divide and Conquer

[Algorithm] C++ 백준 10050번: 블록

초기 BABABA…(길이 2N)을 인접한 2블록 이동으로 A^N B^N 형태로 만든다. 최소 N회가 하한이고, n=3~7 기저 + n-4 해를 평행이동하는 재귀로 정확히 N회를 구성한다.

12월 20, 2025
3 minute read
Featured image of post [Algorithm] C++ 백준 13543번: 수열과 쿼리 2
Algorithm BOJ Data Structure Treap Randomized BST Implicit Treap Binomial Theorem Polynomial

[Algorithm] C++ 백준 13543번: 수열과 쿼리 2

삽입/삭제/갱신이 있는 동적 수열에서 구간 다항 가중합을 구한다. implicit treap에 ΣAi·i^k(0≤k≤10)을 저장하고 이항정리로 merge 시 shift를 계산해 O(K^2 log N)으로 처리한다.

12월 20, 2025
4 minute read
Featured image of post [Algorithm] C++ 백준 17372번: 피보나치 수의 최대공약수의 합
Algorithm BOJ Number Theory Mobius Inversion Fibonacci

[Algorithm] C++ 백준 17372번: 피보나치 수의 최대공약수의 합

gcd(Fi,Fj)=F_gcd(i,j) 성질을 이용해 이중합을 Möbius 반전으로 Σ g(d)⌊n/d⌋²로 바꾸고, Mertens 함수 + 피보나치 fast doubling으로 n≤1e9을 처리한다.

12월 20, 2025
5 minute read
Featured image of post [Algorithm] C++ 백준 32231번: 재우의 삼수강
Algorithm BOJ Geometry Calculus Hyperbolic Geometry

[Algorithm] C++ 백준 32231번: 재우의 삼수강

밀도 ρ=1/y인 수영장에서 단위거리 이동 시간이 ρ초이므로, 총 시간은 ∫(ds/y)로 주어진다. 이는 상반평면 모델의 쌍곡거리이며 acosh(1+Δ/(2y1y2))로 최소 시간을 O(1)에 계산한다.

12월 20, 2025
2 minute read
Featured image of post [Algorithm] C++ 백준 3752번: 최대공약수 행렬식
Algorithm BOJ Number Theory Matrix Determinant

[Algorithm] C++ 백준 3752번: 최대공약수 행렬식

인수에 대해 닫힌 집합 S에서 gcd(xi,xj)로 만든 GCD 행렬의 행렬식은 Smith 정리에 의해 ∏_{x∈S} φ(x)로 단순화된다. 각 원소를 소인수분해해 오일러 피함수를 곱해 mod 1e9+7로 계산한다.

12월 20, 2025
3 minute read
Featured image of post [PowerShell] Frontmatter Description 누락 파일 찾기
PowerShell Hugo

[PowerShell] Frontmatter Description 누락 파일 찾기

Cursor/VSCode에서 멀티라인 frontmatter 검색의 한계를 극복하고, PowerShell만으로 description이 없는 마크다운 파일을 찾아내는 방법을 단계별로 안내합니다. draft:true 제외 로직과 정규식 설명 포함.

12월 20, 2025
5 minute read
Featured image of post [Algorithm] C++ 백준 1185번: 유럽여행
Algorithm BOJ Graph MST Kruskal

[Algorithm] C++ 백준 1185번: 유럽여행

도시 방문비와 도로 통행료가 있을 때 모든 도시를 최소 한 번 방문하고 시작점으로 돌아오는 최소 비용을 구한다. 간선 비용을 2L+Cu+Cv로 변형해 크루스칼 MST 후 최소 Cu를 더한다.

12월 19, 2025
4 minute read
Featured image of post [Algorithm] C++ 백준 13324번: BOJ 수열 2
Algorithm BOJ Greedy Priority Queue Data Structure

[Algorithm] C++ 백준 13324번: BOJ 수열 2

A_i-i로 변환해 B1<…<BN 조건을 비내림 제약으로 바꾸고, prefix 중앙값(힙 2번 push 1번 pop)으로 L1 오차 최소를 만든다. 역방향 최소 보정 후 B를 출력한다.

12월 19, 2025
3 minute read
Featured image of post [Algorithm] C++ 백준 13539번: 트리와 쿼리 11
Algorithm BOJ Data Structure Tree Dynamic Tree

[Algorithm] C++ 백준 13539번: 트리와 쿼리 11

루트가 있는 동적 포리스트에서 link/cut과 LCA 쿼리를 처리한다. Link-Cut Tree의 access로 간선 연결/분리와 LCA를 모두 O(log N) 분할상환으로 해결한다.

12월 19, 2025
4 minute read
Featured image of post [Algorithm] C++ 백준 14853번: 동전 던지기
Algorithm BOJ Probability Bayesian Math

[Algorithm] C++ 백준 14853번: 동전 던지기

관측된 앞면 횟수로 각 동전의 확률 p,q의 사후분포를 Beta로 만들고, P(p<q)를 Beta 함수 합으로 닫힌형태 계산한다. 로그 팩토리얼로 수치 안정성을 확보해 T=1e5도 처리한다.

12월 19, 2025
1 minute read
Featured image of post [Algorithm] C++ 백준 14899번: 수열과 쿼리 19
Algorithm Segment Tree Segment Tree Beats

[Algorithm] C++ 백준 14899번: 수열과 쿼리 19

구간 덧셈, 구간 바닥 나눗셈(⌊Ai/d⌋), 구간 최솟값과 구간 합을 처리한다. min/max 기반 가지치기(일괄 set, 동일 delta add)로 floor-div 갱신을 세그먼트 트리 비츠로 최적화한다.

12월 19, 2025
5 minute read
Featured image of post [Algorithm] C++ 백준 15249번: Building Bridges
Algorithm BOJ DP Convex Hull Trick

[Algorithm] C++ 백준 15249번: Building Bridges

기둥 일부만 선택해 1번부터 n번까지 다리를 잇는다. 구간 연결 비용 (hi-hj)^2와 선택되지 않은 기둥 제거 비용 wi를 합쳐 최소화한다. DP를 세우고 Li Chao Tree로 O(n log H)에 최적화한다.

12월 19, 2025
2 minute read
Featured image of post [Algorithm] C++ 백준 16745번: What Goes Up Must Come Down
Algorithm BOJ Fenwick Tree

[Algorithm] C++ 백준 16745번: What Goes Up Must Come Down

인접 스왑만으로 수열을 비토닉(비감소 후 비증가) 형태로 재배열할 때 필요한 최소 스왑 수를 구한다. 각 원소를 좌/우 구간에 둘 때의 ‘큰 값과의 역전’ 비용을 Fenwick Tree로 계산해 값별 최적 분할을 합산한다.

12월 19, 2025
4 minute read
Featured image of post [Algorithm] C++ 백준 16895번: 님 게임 3
Algorithm BOJ Game Theory Bitwise

[Algorithm] C++ 백준 16895번: 님 게임 3

전체 돌더미의 XOR(님합)이 0이면 선공은 필패다. 아니면 어떤 더미 pi를 pi^X로 줄여 님합을 0으로 만드는 모든 첫 수가 승리 수이며, 이를 O(N)으로 센다.

12월 19, 2025
2 minute read
Featured image of post [Algorithm] C++ 백준 17441번: 파리채 만들기
Algorithm BOJ Math Geometry Green's Theorem

[Algorithm] C++ 백준 17441번: 파리채 만들기

단순다각형 내부에서 두 점을 균일·독립으로 뽑을 때 E[|P-Q|^2]를 구한다. 이를 2(E[|P|^2]-|E[P]|^2)로 바꾸고 면적·무게중심·∫x^2,∫y^2를 변 합 공식으로 O(N)에 계산한다.

12월 19, 2025
3 minute read
Featured image of post [Algorithm] C++ 백준 1777번: 순열복원
Algorithm BOJ Data Structure Fenwick Tree Order Statistics

[Algorithm] C++ 백준 1777번: 순열복원

Inversion sequence(각 i 뒤에 나오며 i보다 작은 수의 개수)로부터 Fenwick Tree(BIT)에서 k번째 빈 칸을 찾아 큰 수부터 배치해 순열을 복원한다. O(N log N)으로 N≤100000을 처리한다.

12월 19, 2025
4 minute read
Featured image of post [Algorithm] C++ 백준 17965번: Absolute Game
Algorithm BOJ Game Theory Greedy

[Algorithm] C++ 백준 17965번: Absolute Game

각자 자신의 배열에서 하나만 남길 때까지 번갈아 삭제한다. 게임 값은 max_x min_y |x-y|로 환원되며, b를 정렬한 뒤 각 a의 최근접 거리 최댓값을 lower_bound로 계산한다.

12월 19, 2025
4 minute read
Featured image of post [Algorithm] C++ 백준 20176번: Needle
Algorithm BOJ Math FFT Convolution Geometry

[Algorithm] C++ 백준 20176번: Needle

세 장벽(위·중·아래) 구멍 3점이 일직선이면 중간 x는 위·아래 x의 평균이다. 위/아래 좌표를 0/1 배열로 만든 뒤 FFT 컨볼루션으로 합=2xm 쌍을 세어 O(R log R)에 통로 개수를 구한다.

12월 19, 2025
3 minute read
Featured image of post [Algorithm] C++ 백준 20506번: Kaisar - 생존
Algorithm BOJ Tree LCA

[Algorithm] C++ 백준 20506번: Kaisar - 생존

트리에서 모든 순서쌍 (x,y)의 LCA를 모아 정렬한 뒤 홀수/짝수 위치 합을 구한다. 각 정점이 LCA가 되는 쌍의 개수를 서브트리 크기 제곱으로 O(N)에 계산한다.

12월 19, 2025
4 minute read
Featured image of post [Algorithm] C++ 백준 22878번: 간단한 문제
Algorithm BOJ Math Sorting

[Algorithm] C++ 백준 22878번: 간단한 문제

점 (p_i,q_i) 쌍에 대해 모든 i,j의 min(|p_i-p_j|,|q_i-q_j|) 합을 구한다. max(|dx|,|dy|)=(|dx+dy|+|dx-dy|)/2를 이용해 p,q,p+q,p-q를 정렬·누적합으로 처리한다.

12월 19, 2025
1 minute read
1 2 … 38
© 2018 - 2025 42JerryKim
Built with Hugo
Theme Stack designed by Jimmy