답안 #1099417

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1099417 2024-10-11T09:28:03 Z mihaihvh Circle Passing (EGOI24_circlepassing) C++14
20 / 100
2000 ms 1048576 KB
#include <iostream>
#include <set>
#include <queue>
#include <vector>

using namespace std;

vector<set<int>> v;

long long 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;
                if (m == l) {
                    cout << viz[l] - 1 << '\n';
                    return;
                }
            }
        }
        q.pop();
    }
}

int main() {
    cin.tie(NULL);
    cin.sync_with_stdio(false);
    cin >> n >> m >> q;
    vector<set<int>> V(2LL*n);
    v = V;
    for (int i = 0; i < m; ++i) {
        cin >> M;
        v[M].insert(M+n);
        v[M+n].insert(M);
    }
    for (int i = 0; i < 2LL*n; ++i) {
        if (i == 0)
            v[i].insert(2LL*n-1);
        if (i == 2LL*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) {
        int a, b;
        cin >> a >> b;
        bf(a, b);
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 5 ms 496 KB Output is correct
3 Correct 18 ms 540 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Execution timed out 2099 ms 38804 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 4 ms 612 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 9 ms 600 KB Output is correct
9 Correct 12 ms 860 KB Output is correct
10 Correct 9 ms 848 KB Output is correct
11 Correct 9 ms 604 KB Output is correct
12 Correct 9 ms 852 KB Output is correct
13 Correct 11 ms 600 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 4 ms 612 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 9 ms 600 KB Output is correct
9 Correct 12 ms 860 KB Output is correct
10 Correct 9 ms 848 KB Output is correct
11 Correct 9 ms 604 KB Output is correct
12 Correct 9 ms 852 KB Output is correct
13 Correct 11 ms 600 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 3 ms 588 KB Output is correct
23 Correct 4 ms 604 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 4 ms 592 KB Output is correct
28 Correct 9 ms 844 KB Output is correct
29 Correct 12 ms 860 KB Output is correct
30 Correct 9 ms 604 KB Output is correct
31 Correct 10 ms 844 KB Output is correct
32 Correct 10 ms 600 KB Output is correct
33 Correct 9 ms 844 KB Output is correct
34 Correct 1 ms 856 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Runtime error 417 ms 1048576 KB Execution killed with signal 9
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 5 ms 496 KB Output is correct
3 Correct 18 ms 540 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Execution timed out 2099 ms 38804 KB Time limit exceeded
6 Halted 0 ms 0 KB -