답안 #1099377

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1099377 2024-10-11T08:52:09 Z mihaihvh Circle Passing (EGOI24_circlepassing) C++14
컴파일 오류
0 ms 0 KB
#include <fstream>
#include <set>
#include <queue>
#include <vector>

using namespace std;

set<int> v[2001];
vector<pair<int, int>> Q;

int n, m, q;
int M;

void bf(int k, int l) {
    int viz[2001]{0};
    queue<int> q;
    viz[k] = 1;
    q.push(k);
    while (!q.empty()) {
        for (auto m : v[q.front()]) {
            if (!viz[m]) {
                q.push(m);
                viz[m] = viz[q.front()] + 1;
            }
        }
        q.pop();
    }
    cout << viz[l] - 1 << '\n';
}

int main() {
    cin >> n >> m >> q;
    for (int i = 0; i < m; ++i) {
        cin >> M;
        v[M].insert(M+n);
        v[M+n].insert(M);
    }
    for (int i = 0; i < 2*n; ++i) {
        if (i == 0)
            v[i].insert(2*n-1);
        if (i == 2*n-1)
            v[i].insert(0);
        if (i < 2*n-1) v[i].insert(i+1);
        if (i > 0) v[i].insert(i-1);
    }

    for (int i = 0; i < q; ++i) {
        for (int j = 0; j < m; ++j) {
            int a, b;
            cin >> a >> b;
            Q.push_back(make_pair(a, b));
        }
    }

    for (auto p : Q) {
        bf(p.first, p.second);
    }

    return 0;
}

Compilation message

Main.cpp: In function 'void bf(int, int)':
Main.cpp:28:5: error: 'cout' was not declared in this scope
   28 |     cout << viz[l] - 1 << '\n';
      |     ^~~~
Main.cpp:4:1: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
    3 | #include <queue>
  +++ |+#include <iostream>
    4 | #include <vector>
Main.cpp: In function 'int main()':
Main.cpp:32:5: error: 'cin' was not declared in this scope
   32 |     cin >> n >> m >> q;
      |     ^~~
Main.cpp:32:5: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?