본문 바로가기

USACO

(71)
백준 11996 Circular Barn (USACO February 2016 Silver 1번) 문제 링크: https://www.acmicpc.net/problem/11996 11996번: Circular Barn (Silver) Being a fan of contemporary architecture, Farmer John has built a new barn in the shape of a perfect circle. Inside, the barn consists of a ring of \(n\) rooms, numbered clockwise from \(1 \ldots n\) around the perimeter of the barn (\(3 \leq n \leq 1000\) www.acmicpc.net 비어있는 방을 찾아서 반시계 방향으로 제일 가까운 소로 채워넣으면 됨. 소를 옮길때마다 ..
백준 5940 Math Practice (USACO November 2010 Bronze 3번) 문제 링크: https://www.acmicpc.net/problem/5940 5940번: Math Practice One lovely afternoon, Bessie's friend Heidi was helping Bessie review for her upcoming math exam. Heidi presents two integers A (0 B; for(int i = A + 1; i 9) n /= 10; if(n == B) { cout
백준 5939 Race Results (USACO November 2010 Bronze 2번) 문제 링크: https://www.acmicpc.net/problem/5939 5939번: Race Results The herd has run its first marathon! The N (1
백준 5938 Daisy Chains in the Field (USACO November 2010 Bronze 1번) 문제 링크: https://www.acmicpc.net/problem/5938 5938번: Daisy Chains in the Field Farmer John let his N (1 > u >> v; adj[u].push_back(v); adj[v].push_back(u); } dfs(1); if(cnt == n) cout
백준 18788 Swapity Swap (USACO February 2020 Bronze 3번) 문제 링크: https://www.acmicpc.net/problem/18788 18788번: Swapity Swap Initially, the order of the cows is $[1,2,3,4,5,6,7]$ from left to right. After the first step of the process, the order is $[1,5,4,3,2,6,7].$ After the second step of the process, the order is $[1,5,7,6,2,3,4]$. Repeating both steps a second time yields t www.acmicpc.net 배열의 처음 상태로 몇번만에 돌아오는지 period를 먼저 계산하고, 실제로 k번을 반복하는 대신 k % ..
백준 18787 Mad Scientist (USACO February 2020 Bronze 2번) 문제 링크: https://www.acmicpc.net/problem/18787 18787번: Mad Scientist First, FJ can transform the substring that corresponds to the first character alone, transforming $B$ into GHGGGHH. Next, he can transform the substring consisting of the third and fourth characters, giving $A$. Of course, there are other combinations of t www.acmicpc.net 예시 7 GHHHGHH HHGGGHH 앞에서부터 훑으면서 첫번째 자리가 다르므로 한번 toggle해주고,..
백준 18786 Triangles (USACO February 2020 Bronze 1번) 문제 링크: https://www.acmicpc.net/problem/18786 18786번: Triangles (Bronze) Posts at $(0,0)$, $(1,0)$, and $(1,2)$ form a triangle of area $1$. Thus, the answer is $2\cdot 1=2$. There is only one other triangle, with area $0.5$. 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 24 25 26 27 28 29 30 31 32 #include using namespace std; struct coord { int x, y; }; int n; coord..
백준 18323 Photoshoot (USACO January 2020 Bronze 2번) 문제 링크: https://www.acmicpc.net/problem/18323 18323번: Photoshoot Farmer John is lining up his $N$ cows ($2\le N\le 10^3$), numbered $1\ldots N$, for a photoshoot. FJ initially planned for the $i$-th cow from the left to be the cow numbered $a_i,$ and wrote down the permutation $a_1,a_2,\ldots,a_N$ on a sheet of paper. U www.acmicpc.net 예시 1 5 4 6 7 6 첫수를 1부터 4 - 1 까지 시도해 보면서 가능할때 출력하면 됨. 첫수가 1일때:..