목록백준 (2)
혜지와 콩나무
#include #include #include // memset 사용using namespace std;int tmap[50][50]; // 보물 지도int visited[50][50]; // 방문 체크int row, col; // 행(row)과 열(col)// 상하좌우 이동int dy[4] = { -1, 0, 1, 0 };int dx[4] = { 0, 1, 0, -1 };// BFS 함수 (시작점 y, x에서 최장 거리 찾기)int bfs(int y, int x) { memset(visited, 0, sizeof(visited)); // 방문 배열 초기화 visited[y][x] = 1; // 시작점 방문 queue> q; q.push({ y, x }); int max..
#include #include #include using namespace std;int n;int colormap[100][100];int visitedcan[100][100]; // 적록색약 아닌 사람int visitedcant[100][100]; // 적록색약인 사람int dx[4] = { 0, 0, 1, -1 };int dy[4] = { 1, -1, 0, 0 };// 적록색약 아닌 사람의 탐색void bfsCan(int x, int y) { queue> q; visitedcan[x][y] = 1; q.push({ x, y }); while (!q.empty()) { int cx = q.front().first; int cy = q.front().se..