PS (179) 썸네일형 리스트형 백준 1697 숨바꼭질 (C++) #include #include #include #include #include #include #define MAX 51 using namespace std; queue Q; int x, y; bool visited[100001] = {false,}; void BFS() { Q.push(make_pair(x, 0)); visited[x] = true; while (!Q.empty()) { int X = Q.front().first; int T = Q.front().second; Q.pop(); if (X == y) { cout -1 && X - 1 < 100001 && visited[X - 1] == false) { Q.push(make_pair(X - 1, T + 1)); visited[X - 1] .. 백준 1707번 이분 그래프(C++) #include #include #include #define MAX 20001 using namespace std; int V, E; int x, y; int check = 0; vector vertex[MAX]; bool visited[MAX] = { false, }; int vertexCol[MAX] = { 0, }; void setgraph() { cin >> V >> E; for (int i = 0; i > x >> y; vertex[x].push_back(y); vertex[y].push_back(x); } } void DFS(int here) { if (visited[here] == true) return; visited[here] = true; for (int.. 백준 1966번 프린터 큐(C++) #include #include #include #include using namespace std; int S, N, M; int x; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> S; for (int i = 0; i > N >> M; int cnt = 0; for (int j = 0; j > x; Q.push(x); q.push(make_pair(j, x)); } while (!q.empty()) { int index = q.front().first; int value = q.front(.. 이전 1 ··· 20 21 22 23 다음