코딩테스트 128
-
문제 풀이#include #include using namespace std;int box[1002][1002];int dist[1002][1002];int n, m, result;int dy[4] = { -1, 1, 0, 0 };int dx[4] = { 0, 0, -1, 1 };int main(){ cin >> m >> n; for (int y = 0; y > box[y][x]; dist[y][x] = -1; } } queue> q; for (int y = 0; y = n || nx = m) { continue; } if (box[ny][nx] == -1 || dist[ny][nx] != -1) { continue; } } } int result = 0; for (..
-
-
문제 풀이#include #include #include using namespace std;int maze[102][102];int dist[102][102];int n, m;int dx[4] = { -1, 1, 0, 0 };int dy[4] = { 0, 0, -1, 1 };int bfs() { queue> q; q.push({ 0, 0 }); dist[0][0] = 1; while (!q.empty()) { int x = q.front().first; int y = q.front().second; q.pop(); for (int dir = 0; dir = n || ny = m) continue; if (dist..
-
-
-
문제 풀이#include #include using namespace std;int paper[502][502];bool visited[502][502];int n, m;// 상, 하, 좌, 우 이동 방향int dx[4] = { -1, 1, 0, 0 };int dy[4] = { 0, 0, -1, 1 };int bfs(int x, int y){ queue> q; q.push({ x, y }); visited[x][y] = true; int area = 1; while (!q.empty()) { int cur_x = q.front().first; int cur_y = q.front().second; q.pop(); for (int i = 0; i = n || ny >= m) continue; ..
-
-