[C++] 백준 1697 숨바꼭질 BFS
·
Algorithm/Baekjoon
#include #include #define MAX_LOCATION 100001 using namespace std; int K, N; int visited[MAX_LOCATION]{false}; void BFS(int curr); int main() { ios::sync_with_stdio(false); cin >> N >> K; BFS(N); } void BFS(int curr) { queue q; q.push({ curr, 0 }); visited[curr] = true; while (!q.empty()) { int currNode = q.front().first; int currSec = q.front().second; q.pop(); if (currNode == K) { cout currNod..