[BOJ] 11123번 양 한마리... 양 두마리... (C++)
https://www.acmicpc.net/problem/11123 11123번: 양 한마리... 양 두마리... 얼마전에 나는 불면증에 시달렸지... 천장이 뚫어져라 뜬 눈으로 밤을 지새우곤 했었지. 그러던 어느 날 내 친구 광민이에게 나의 불면증에 대해 말했더니 이렇게 말하더군. "양이라도 세봐!" www.acmicpc.net #include #include #include using namespace std; int t, h, w, cnt = 0; char arr[100][100]; bool visited[100][100]; int dx[4] = { -1, 0, 0, 1 }; int dy[4] = { 0, -1, 1, 0 }; void bfs(int a, int b){ queue q; q.push(..
[BOJ] 3184번 양 (C++)
https://www.acmicpc.net/problem/3184 3184번: 양 첫 줄에는 두 정수 R과 C가 주어지며(3 ≤ R, C ≤ 250), 각 수는 마당의 행과 열의 수를 의미한다. 다음 R개의 줄은 C개의 글자를 가진다. 이들은 마당의 구조(울타리, 양, 늑대의 위치)를 의미한다. www.acmicpc.net #include #include using namespace std; int r, c; char arr[250][250]; bool visited[250][250]; int dx[4] = { -1, 0, 0, 1 }; int dy[4] = { 0, -1, 1, 0 }; int cs = 0, cw = 0; void bfs(int a, int b){ int ts = 0, tw = 0; q..
[BOJ] 2589번 보물섬 (C++)
https://www.acmicpc.net/problem/2589 2589번: 보물섬 보물섬 지도를 발견한 후크 선장은 보물을 찾아나섰다. 보물섬 지도는 아래 그림과 같이 직사각형 모양이며 여러 칸으로 나뉘어져 있다. 각 칸은 육지(L)나 바다(W)로 표시되어 있다. 이 지도에서 www.acmicpc.net #include #include using namespace std; int n, m; char arr[50][50]; int path[50][50] = {-1, }; int dx[4] = {0, 0, -1, 1}; int dy[4] = {-1, 1, 0, 0}; int maxlen = 0; void bfs(int x, int y){ queue q; q.push({x, y}); path[x][y] =..
[Programmers] 거리두기 확인하기 (C++)
https://programmers.co.kr/learn/courses/30/lessons/81302 코딩테스트 연습 - 거리두기 확인하기 [["POOOP", "OXXOX", "OPXPX", "OOXOX", "POXXP"], ["POOPX", "OXPXP", "PXXXO", "OXXXO", "OOOPP"], ["PXOPX", "OXOXP", "OXPOX", "OXXOP", "PXPOX"], ["OOOXX", "XOOOX", "OOOXX", "OXOOX", "OOOOO"], ["PXPXP", "XPXPX", "PXPXP", "XPXPX", "PXPXP"]] [1, 0, 1, 1, 1] programmers.co.kr #include #include #include #include using namespac..