본문 바로가기

USACO/Silver

(15)
백준 14465 소가 길을 건너간 이유 5 (USACO February 2017 Silver 2번) 문제 링크: https://www.acmicpc.net/problem/14465 14465번: 소가 길을 건너간 이유 5 문제 농부 존의 농장에 원형 길이 있다고 했지만, 길은 그뿐만이 아니다. 그 옆에 일자형 길이 있는데, 1번부터 N번까지의 번호가 붙은 횡단보도 N (1 ≤ N ≤ 100,000)개로 이루어져 있다. 교통사고를 방지하기 위해 존은 각 횡단보도에 신호등을 설치해 놓았다. 그러던 어느 날, 강력한 뇌우로 인해 몇몇 신호등이 망가졌다. 존은 연속한 K개의 신호등이 존재하도록 신호등을 수리하고 싶다. 이번에도 우리가 존을 도와주자. 입력 첫 줄에 N, K, B www.acmicpc.net 1. Sliding Window, Line Sweeping 처음 k개중에 작동하는 신호등의 갯수를 센 후..
백준 14464 소가 길을 건너간 이유 4 (USACO February 2017 Silver 1번) 문제 링크: https://www.acmicpc.net/problem/14464 14464번: 소가 길을 건너간 이유 4 문제 농부 존의 소들은 효율적으로 길을 건너는 방법을 터득하고 있다. 그들은 길 건너기의 달인인 닭의 도움을 받기로 했다. 안타깝게도 닭은 매우 바쁜 동물이라, 소를 도와줄 시간이 별로 없다. 농장에 C마리(1 ≤ C ≤ 20,000)의 닭이 있고, 1번부터 C번까지 번호가 붙어 있다. i번 닭은 정확히 Ti초에만 소를 도와줄 수 있다. 하지만 닭은 길 건너기의 달인이므로 소를 데리고도 순식간에 길을 건널 수 있다. 소는 할 일이 없어서 여유롭게 길을 건 www.acmicpc.net Binary Search (lower_bound) 소가 A에서 B사이에 길을 건너는데, B를 기준으로 ..
백준 14454 Secret Cow Code (USACO January 2017 Silver 3번) 문제 링크: https://www.acmicpc.net/problem/14454 14454번: Secret Cow Code The cows are experimenting with secret codes, and have devised a method for creating an infinite-length string to be used as part of one of their codes. Given a string s, let F(s) be s followed by s "rotated" one character to the right (in a right rotation www.acmicpc.net 주어진 index가 길이가 두배가 되기전 어떤 index에서 온것인지 역추적 하면 됨. 예시 COW ..
백준 14453 Hoof, Paper, Scissors (USACO January 2017 Silver 2번) 문제 링크: https://www.acmicpc.net/problem/14453 14453번: Hoof, Paper, Scissors (Silver) You have probably heard of the game "Rock, Paper, Scissors". The cows like to play a similar game they call "Hoof, Paper, Scissors". The rules of "Hoof, Paper, Scissors" are simple. Two cows play against each-other. They both count to three and then each s www.acmicpc.net Prefix Sum 1 2 3 4 5 6 7 8 9 10 11 12 13 ..
백준 14452 Cow Dance Show (USACO January 2017 Silver 1번) 문제 링크: https://www.acmicpc.net/problem/14452 14452번: Cow Dance Show After several months of rehearsal, the cows are just about ready to put on their annual dance performance; this year they are performing the famous bovine ballet "Cowpelia". The only aspect of the show that remains to be determined is the size of the stage www.acmicpc.net Binary Search 예시 5 8 4 7 8 6 4 state에 한꺼번에 올라갈수 있는 소들의 수 ..
백준 14172 Moocast (USACO December 2016 Silver 3번) 문제 링크: https://www.acmicpc.net/problem/14172 14172번: Moocast Write a single line of output containing the maximum number of cows a broadcast from a single cow can reach. The originating cow is included in this number. www.acmicpc.net DFS 각 cow마다 얼마나 많은 다른 소한테 연결될수 있는지를 구하고, 그 중 최대값을 구하면 됨. 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 32 33 34 35 36 37 38 39..
백준 14171 Cities and States (USACO December 2016 Silver 2번) 문제 링크: https://www.acmicpc.net/problem/14171 14171번: Cities and States To keep his cows intellectually stimulated, Farmer John has placed a large map of the USA on the wall of his barn. Since the cows spend many hours in the barn staring at this map, they start to notice several curious patterns. For example, the cities of Fl www.acmicpc.net city, state의 앞 두 letter들을 네자리수로 만들어서 state들을 기준으로 vect..
백준 14170 Counting Haybales (USACO December 2016 Silver 1번) 문제 링크: https://www.acmicpc.net/problem/14170 14170번: Counting Haybales Farmer John has just arranged his N haybales (1≤N≤100,000) at various points along the one-dimensional road running across his farm. To make sure they are spaced out appropriately, please help him answer Q queries (1≤Q≤100,000), each asking for the number www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 #..