백준 2644 c++ 촌수계산


백준 2644 c++ 촌수계산

#include #include #include #include #include #include using namespace std; int n; pairtarget; vectorrel[1001]; bool visited[1001][1001]; int m; int t1, t2; int bfs(int start) { queueq; q.push({start,0}); //start는 탐색을 시작할 위치이며, 0은 탐색이 진행될때마다 증가되는 촌수이다. while (!q.empty()) { int qx = q.front().first; //현재위치 int qcnt = q.front().second; //촌수 q.pop(); if (qx == target.second) //촌수를 계산해야하는사람에 도달한 경우 r..


원문링크 : 백준 2644 c++ 촌수계산