본문 바로가기

USACO

(71)
백준 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 ..
백준 5959 Crop Circles (USACO January 2011 Bronze 4번) 문제 링크: https://www.acmicpc.net/problem/5959 5959번: Crop Circles Bessie and her fellow herd-mates have become extremely territorial. The N (1 > r[i]; for(int i = 0; i
백준 5958 Space Exploration (USACO January 2011 Bronze 3번) 문제 링크: https://www.acmicpc.net/problem/5958 5958번: Space Exploration Farmer John's cows have finally blasted off from earth and are now floating around space in their Moocraft. The cows want to reach their fiery kin on Jupiter's moon of Io, but to do this they must first navigate through the dangerous asteroid belt. Bessie www.acmicpc.net DFS component의 갯수를 세면 됨. 1 2 3 4 5 6 7 8 9 10 11 12 13 14..
백준 5957 Cleaning the Dishes (USACO January 2011 Bronze 2번) 문제 링크: https://www.acmicpc.net/problem/5957 5957번: Cleaning the Dishes Bessie and Canmuu are teaming up to wash the massive pile of N (1 n; for(int i = n; i >= 1; i--) a.push(i); while(c.size() != n) { int u, v; cin >> u >> v; if(u == 1) { while(v--) { b.push(a.top()); a.pop(); } } else { while(v--) { c.push(b.top()); b.pop(); } } } while(!c.empty()) { cout
백준 5956 Symmetry (USACO January 2011 Bronze 1번) 문제 링크: https://www.acmicpc.net/problem/5956 5956번: Symmetry Farmer John loves symmetry and is currently arranging his cows on his field partitioned into an N x M (1 m; int ans = 0, r = 1; while(n % 2 == 1 && m % 2 == 1) { ans += r; n /= 2; m /= 2; r *= 4; } cout
백준 5949 Adding Commas (USACO December 2010 Bronze 3번) 문제 링크: https://www.acmicpc.net/problem/5949 5949번: Adding Commas Bessie is working with large numbers N (1 s; int sz = s.size(); if(sz > 9) { s.insert(1, ","); s.insert(5, ","); s.insert(9, ","); } else if(sz > 6) { s.insert(sz - 6, ","); s.insert(sz - 2, ","); } else if(sz > 3) { s.insert(sz - 3, ","); } cout Colored by Color Scripter