[백준][bfs] 14497 주난의 난 c++ 구현
목차https://www.acmicpc.net/problem/14497문제 문제 구현 방향bfs와 dfs를 활용하면 풀 수 있는 문제였다.bfs를 통해 경로를 계산해주고 dfs를 통해 퍼져나가는 파동을 구현해주면 된다. 코드 구현#include #include #include #include #include using namespace std;int dx[4] = {0, 0, 1, -1};int dy[4] = { 1, -1, 0, 0 };int N, M, startX, startY, endX, endY;char board[300][300] = { 0 };int visit[300][300] = { 0 };queue> q;//파동이 퍼지는 것을 위한 dfsvoid dfs(int x, int y, int ..
2024. 6. 27.
[백준][bfs] 12869 뮤탈리스크 c++구현
목차https://www.acmicpc.net/problem/12869문제 문제 구현 시 주의점#include #include #include#includeusing namespace std;int start2[2][2] = { {9, 3 }, { 3, 9 } };int start3[6][3] = { {9, 3, 1 }, {9, 1, 3}, {3, 9, 1}, {3, 1, 9}, {1, 3, 9}, {1, 9, 3} };struct SCV { vector scv; int depth;};vector scv;vector ans;void print(vector t) { for (int i = 0; i q; q.push({ scv, 0 }); int cnt = 0; while (!q.empty()) { ..
2024. 6. 20.