본문 바로가기

BOJ

(56)
[BOJ 5551] 쇼핑몰 https://www.acmicpc.net/problem/5551 5551번: 쇼핑몰 첫째 줄에 도시의 수 N, 도로의 수 M, 쇼핑몰이 있는 도시의 수 K가 주어진다. 도시는 1번부터 N번까지 번호가 매겨져 있다. (2 ≤ N ≤ 3000, 1 ≤ M ≤ 105, 1 ≤ K ≤ N) 다음 M개 줄에는 도로의 정보 a, b, www.acmicpc.net Tag : dijkstra 문제 요약 정점마다 가장 가까운 쇼핑몰과의 거리를 \(A_i\)라 정의할 때 이 \(A_i\)의 최대를 구하는 문제다. 풀이 최단경로...->최소.....최대........ 파라메트릭?하면서 뇌절할뻔했다. 가장 멀리 있는 집은 어떠한 간선의 양 끝 또는 간선 위에 존재한다. 그래서 모든 간선을 확인하면서 \(\lceil (dis..
[BOJ 15732] 도토리 숨기기 https://www.acmicpc.net/problem/15732 15732번: 도토리 숨기기 첫째 줄에 상자의 개수 N(1 ≤ N ≤ 1,000,000)과 규칙의 개수 K(1 ≤ K ≤ 10,000), 도토리의 개수 D(1 ≤ D ≤ 1,000,000,000)가 주어진다. 그 후 K개 줄에는 A, B, C(1 ≤ C ≤ A ≤ B ≤ N)가 주어지며 A번 상자부터 www.acmicpc.net Tag : binary search 문제 요약 "\([l,r]\)에서 x간격으로 도토리를 하나씩 배치한다." 라는 규칙이 \(K\)개 존재한다. 이 때 \(D\)번째 도토리가 위치한 상자를 찾는 문제다. 풀이 1~i까지 상자의 도토리 개수 합이 단조증가하기 때문에 이분탐색을 사용할 수 있다. 1~i까지의 도토리 ..
[BOJ 5837] Poker Hands https://www.acmicpc.net/problem/5837 5837번: Poker Hands Output Details Bessie can play a straight from 1 to 5, a straight from 1 to 2, a straight from 4 to 5, two straights from 2 to 2, and a straight from 5 to 5, for a total of 6 rounds necessary to get rid of all her cards. www.acmicpc.net Tag : Greedy 문제요약 구간 [l,r]의 모든 원소를 1씩 줄일 수 있는 연산이 있고 모든 원소를 0으로 만드는 것이 목표일 때 최소 연산 횟수를 구하는 문제다. 풀이 가능한 선에..
[BOJ 5846] Wifi Setup https://www.acmicpc.net/problem/5864 5864번: Wifi Setup Farmer John's N cows (1 N>>A>>B; for(int i=1;i>v[i]; v[i]*=2; } sort(v+1,v+1+N); for(int i=1;i
[BOJ 10403] Intrepid climber https://www.acmicpc.net/problem/10403 10403번: Intrepid climber The first line contains two integers N and F (1 ≤ F < N ≤ 105), representing respectively the number of landmarks and the number of your friends that are climbing the mountain. Landmarks are identified with distinct integers from 1 to N, being 1 the to www.acmicpc.net Tag : Greedy, Tree dp 문제요약 트리 위에 F개의 랜드마크가 존재하는데, 1번노드에서 출발해 모든 랜드..
[BOJ 20531] 인간관계 https://www.acmicpc.net/problem/20531 20531번: 인간관계 S인터넷고등학교에는 $N$명의 학생이 있다. 이들 사이에 몇몇은 서로 친구 관계를 맺고 있다. 친구 관계는 다음 세 가지 조건을 만족한다. 모든 학생은 자기 자신의 친구이다. 학생 $x$가 학생 $y$ www.acmicpc.net Tag : combinatorics, prefix sum 문제 요약 N명의 사람을 K개의 그룹으로 분할하는 경우의 수 \(dp_{N,K}\)는 \(\sum{\binom{N}{j}*dp_{N-j,K}}\)처럼 표현할 수도 있지만 좀 계산하기 쉬운 형태로도 나타낼 수 있다. \(dp_{i,j}=dp_{i-1,j-1} + j \times dp_{i-1,j}\) 이 식을 토대로 계산만 해주면 된..
[BOJ 11997] Load Balancing (silver) https://www.acmicpc.net/problem/11997 11997번: Load Balancing (Silver) Farmer John's \(N\) cows are each standing at distinct locations \((x_1, y_1) \ldots (x_N, y_N)\) on his two-dimensional farm (\(1 \leq N \leq 1000\), and the \(x_i\)'s and \(y_i\)'s are positive odd integers of size at most \(1,000,000\)). FJ wants to par www.acmicpc.net Tag : brute force, prefix sum, coordinate compression 문..
[BOJ 23569] Friendship Graph https://www.acmicpc.net/problem/23569 23569번: Friendship Graphs Given a collection of people who interact, we can define a graph whose vertices are people, with an edge between two people if and only if they are friends with one another. Such graphs are called social networks and are well defined on any set of people, www.acmicpc.net Tag : graph theory, knapsack dp 문제요약 주어진 그래프를 두개의 clique로 쪼개라...