Submission #1099378

# Submission time Handle Problem Language Result Execution time Memory
1099378 2024-10-11T08:52:27 Z mihaihvh Circle Passing (EGOI24_circlepassing) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <set>
#include <queue>
#include <vector>

using namespace std;

ifstream cin("in.in");
ofstream cout("out.out");

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:8:13: error: variable 'std::ifstream cin' has initializer but incomplete type
    8 | ifstream cin("in.in");
      |             ^
Main.cpp:9:14: error: variable 'std::ofstream cout' has initializer but incomplete type
    9 | ofstream cout("out.out");
      |              ^
Main.cpp: In function 'void bf(int, int)':
Main.cpp:32:5: error: reference to 'cout' is ambiguous
   32 |     cout << viz[l] - 1 << '\n';
      |     ^~~~
In file included from Main.cpp:1:
/usr/include/c++/10/iostream:61:18: note: candidates are: 'std::ostream std::cout'
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
Main.cpp:9:10: note:                 '<typeprefixerror>cout'
    9 | ofstream cout("out.out");
      |          ^~~~
Main.cpp: In function 'int main()':
Main.cpp:36:5: error: reference to 'cin' is ambiguous
   36 |     cin >> n >> m >> q;
      |     ^~~
In file included from Main.cpp:1:
/usr/include/c++/10/iostream:60:18: note: candidates are: 'std::istream std::cin'
   60 |   extern istream cin;  /// Linked to standard input
      |                  ^~~
Main.cpp:8:10: note:                 '<typeprefixerror>cin'
    8 | ifstream cin("in.in");
      |          ^~~
Main.cpp:38:9: error: reference to 'cin' is ambiguous
   38 |         cin >> M;
      |         ^~~
In file included from Main.cpp:1:
/usr/include/c++/10/iostream:60:18: note: candidates are: 'std::istream std::cin'
   60 |   extern istream cin;  /// Linked to standard input
      |                  ^~~
Main.cpp:8:10: note:                 '<typeprefixerror>cin'
    8 | ifstream cin("in.in");
      |          ^~~
Main.cpp:54:13: error: reference to 'cin' is ambiguous
   54 |             cin >> a >> b;
      |             ^~~
In file included from Main.cpp:1:
/usr/include/c++/10/iostream:60:18: note: candidates are: 'std::istream std::cin'
   60 |   extern istream cin;  /// Linked to standard input
      |                  ^~~
Main.cpp:8:10: note:                 '<typeprefixerror>cin'
    8 | ifstream cin("in.in");
      |          ^~~