공부/PS (백준)
-
[BOJ] 17086 아기 상어 2 / C++공부/PS (백준) 2022. 3. 29. 23:14
https://www.acmicpc.net/problem/17086 17086번: 아기 상어 2 첫째 줄에 공간의 크기 N과 M(2 ≤ N, M ≤ 50)이 주어진다. 둘째 줄부터 N개의 줄에 공간의 상태가 주어지며, 0은 빈 칸, 1은 아기 상어가 있는 칸이다. 빈 칸의 개수가 한 개 이상인 입력만 주어진다. www.acmicpc.net #include #include #include using namespace std; int N, M; // 2 = M || visited[nr][nc]) continue; visited[nr][nc] = 1; q.push({ nr,nc, cur_t + 1 }); } } return 0; } void solve() { for (int i = 0; i < blank_sp..
-
[BOJ] 21608 상어 초등학교 / C++공부/PS (백준) 2021. 10. 8. 02:36
#include #include #include using namespace std; int N; struct st { int num; int friends[4]; }; struct st students[20 * 20 + 10]; int seats[20 + 10][20 + 10]; // (1, 1) ~ (N, N) int dx[4] = { -1,1,0,0 }; int dy[4] = { 0,0,-1,1 }; int cur_x, cur_y; struct cand { int x, y; int cnt_empty; int cnt_friends; }; vector candidates; bool cmp(cand &vec1, cand &vec2) { if (vec1.cnt_friends > vec2.cnt_friend..