본문 바로가기

USACO

(71)
백준 17039 Sleepy Cow Herding (USACO February 2019 Bronze 1번) 문제 링크: https://www.acmicpc.net/problem/17039 17039번: Sleepy Cow Herding (Bronze) The minimum number of moves is 1 --- if Farmer John moves the cow in position 4 to position 8, then the cows are at consecutive locations 7, 8, 9. The maximum number of moves is 2. For example, the cow at position 9 could be moved to position 6, then the c www.acmicpc.net 최소값 1. 세개의 수가 모두 붙어있을때는 0임. 2. 연속된 두수의 차이가 2..
백준 17029 Guess the Animal (USACO January 2019 Bronze 3번) 문제 링크: https://www.acmicpc.net/problem/17029 17029번: Guess the Animal The first line of input contains the number of animals, $N$ ($2 \leq N \leq 100$). Each of the next $N$ lines describes an animal. The line starts with the animal name, then an integer $K$ ($1 \leq K \leq 100$), then $K$ characteristics of that animal. Ani www.acmicpc.net 각각의 pair of animals 마다 두마리 모두 가지고 있는 특징의 갯수들의 최대값을 구해서 ..
백준 17028 Sleepy Cow Sorting (USACO January 2019 Bronze 2번) 문제 링크: https://www.acmicpc.net/problem/17028 17028번: Sleepy Cow Sorting Farmer John is attempting to sort his $N$ cows ($1 \leq N \leq 100$), conveniently numbered $1 \dots N$, before they head out to the pastures for breakfast. Currently, the cows are standing in a line in the order $p_1, p_2, p_3, \dots, p_N$, and Farmer Joh www.acmicpc.net 뒤에서부터 제대로 정렬이 된 갯수를 전체 갯수에서 빼면 됨. 1 2 3 4 5 6 7 8 9 1..
백준 17027 Shell Game (USACO January 2019 Bronze 1번) 문제 링크: https://www.acmicpc.net/problem/17027 17027번: Shell Game The first line of the input file contains an integer $N$ giving the number of swaps ($1 \leq N \leq 100$). Each of the next $N$ lines describes a step of the game and contains three integers $a$, $b$, and $g$, indicating that shells $a$ and $b$ were swappe www.acmicpc.net 처음에 pebble이 1번에 있을때, 2번에 있을때, 3번에 있을때 각각의 상황에 따라 맞은 guess의 갯수..
백준 16770 The Bucket List (USACO December 2018 Bronze 2번) 문제 링크: https://www.acmicpc.net/problem/16770 16770번: The Bucket List In this example, FJ needs 4 buckets: He uses buckets 1 and 2 for milking cow 3 (starting at time 2). He uses bucket 3 for milking cow 1 (starting at time 4). When cow 2 arrives at time 8, buckets 1 and 2 are now available, but not bucket 3, so he uses buck www.acmicpc.net 각 소마다의 time interval에 필요한 bucket수를 t 배열에 더해주고 나서, 최대값을 구..
백준 16769 Mixing Milk (USACO December 2018 Bronze 1번) 문제 링크: https://www.acmicpc.net/problem/16769 16769번: Mixing Milk The first line of the input file contains two space-separated integers: the capacity $c_1$ of the first bucket, and the amount of milk $m_1$ in the first bucket. Both $c_1$ and $m_1$ are positive and at most 1 billion, with $c_1 \geq m_1$. The second and t www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ..
백준 11975 Build Gates (USACO January 2016 Silver 3번) 문제 링크: https://www.acmicpc.net/problem/11975 11975번: Build Gates The first line of input contains \(N\) (\(1 \leq N \leq 1000\)). The next line contains a string of length \(N\) describing FJ's path. Each character is either N (north), E (east), S (south), or W (west). www.acmicpc.net BFS 방향 char를 하나 받을때마다 두칸씩 해당 방향으로 움직이면서 fence를 설치함. 다 설치하고 나서, fence가 없는곳에서 bfs를 실행시키고, 실행 횟수에서 1을 빼면 답임. 1 2 3 ..
백준 15763 Team Tic Tac Toe (USACO US Open 2018 Bronze 1번) 문제 링크: https://www.acmicpc.net/problem/15763 15763번: Team Tic Tac Toe In this example, no single cow can claim victory. However, if cows C and X team up, they can win via the C-X-C diagonal. Also, if cows X and O team up, they can win via the middle row. www.acmicpc.net CCC CAA CAA 위의 예시에서와 같이, CCC가 첫번째 row와 첫번째 column에 총 두번 등장하지만, 한번만 세야함. set을 이용해서 중복을 쉽게 처리해줄수 있음. 1 2 3 4 5 6 7 8 9 10 11 12 1..