답안 #1099385

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1099385 2024-10-11T08:56:55 Z mihaihvh Circle Passing (EGOI24_circlepassing) C++14
0 / 100
2000 ms 95744 KB
#include <iostream>
#include <set>
#include <queue>
#include <vector>

using namespace std;

vector<set<int>> v(1000000);
vector<pair<int, int>> Q;


int n, m, q;
int M;

void bf(int k, int l) {
    //int viz[20001]{0};
    vector<int> viz(2*n);
    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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 47708 KB Output is correct
2 Correct 30 ms 47708 KB Output is correct
3 Correct 56 ms 47648 KB Output is correct
4 Correct 20 ms 47452 KB Output is correct
5 Execution timed out 2072 ms 67076 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 47588 KB Output is correct
2 Correct 27 ms 47452 KB Output is correct
3 Correct 27 ms 47432 KB Output is correct
4 Incorrect 23 ms 47452 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 47588 KB Output is correct
2 Correct 27 ms 47452 KB Output is correct
3 Correct 27 ms 47432 KB Output is correct
4 Incorrect 23 ms 47452 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 55 ms 95744 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 47708 KB Output is correct
2 Correct 30 ms 47708 KB Output is correct
3 Correct 56 ms 47648 KB Output is correct
4 Correct 20 ms 47452 KB Output is correct
5 Execution timed out 2072 ms 67076 KB Time limit exceeded
6 Halted 0 ms 0 KB -