Submission #1099410

# Submission time Handle Problem Language Result Execution time Memory
1099410 2024-10-11T09:20:43 Z andreiqwer Circle Passing (EGOI24_circlepassing) C++17
20 / 100
2000 ms 1035344 KB
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

int n, m, q;
vector<int> ad[10000001];

int dist[10000001];
void bfs(int k)
{
    memset(dist, 0, 8*n);
    dist[k]=1;
    queue<int> q;
    q.push(k);
    while(!q.empty())
    {
        int node=q.front();
        q.pop();

        for(auto& x : ad[node])
        {
            if(!dist[x])
            {
                dist[x]=dist[node]+1;
                q.push(x);
            }
        }
    }
}

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

    for(int i=0; i<m; i++)
    {
        int k;
        cin>>k;
        ad[k].push_back(k+n);
        ad[k+n].push_back(k);
    }

    for(int i=1; i<=q; i++)
    {
        int x, y;
        cin>>x>>y;
        bfs(x);
        cout<<dist[y]-1<<'\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 115 ms 235092 KB Output is correct
2 Correct 128 ms 235216 KB Output is correct
3 Correct 143 ms 235088 KB Output is correct
4 Correct 102 ms 235088 KB Output is correct
5 Execution timed out 2081 ms 242384 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 103 ms 235088 KB Output is correct
2 Correct 106 ms 235268 KB Output is correct
3 Correct 95 ms 235148 KB Output is correct
4 Correct 95 ms 235148 KB Output is correct
5 Correct 101 ms 235256 KB Output is correct
6 Correct 96 ms 235092 KB Output is correct
7 Correct 100 ms 235092 KB Output is correct
8 Correct 106 ms 235088 KB Output is correct
9 Correct 111 ms 235096 KB Output is correct
10 Correct 111 ms 235092 KB Output is correct
11 Correct 109 ms 235144 KB Output is correct
12 Correct 110 ms 235092 KB Output is correct
13 Correct 121 ms 235092 KB Output is correct
14 Correct 103 ms 235344 KB Output is correct
15 Correct 98 ms 235092 KB Output is correct
16 Correct 103 ms 235088 KB Output is correct
17 Correct 104 ms 235088 KB Output is correct
18 Correct 96 ms 235092 KB Output is correct
19 Correct 86 ms 235092 KB Output is correct
20 Correct 85 ms 235088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 103 ms 235088 KB Output is correct
2 Correct 106 ms 235268 KB Output is correct
3 Correct 95 ms 235148 KB Output is correct
4 Correct 95 ms 235148 KB Output is correct
5 Correct 101 ms 235256 KB Output is correct
6 Correct 96 ms 235092 KB Output is correct
7 Correct 100 ms 235092 KB Output is correct
8 Correct 106 ms 235088 KB Output is correct
9 Correct 111 ms 235096 KB Output is correct
10 Correct 111 ms 235092 KB Output is correct
11 Correct 109 ms 235144 KB Output is correct
12 Correct 110 ms 235092 KB Output is correct
13 Correct 121 ms 235092 KB Output is correct
14 Correct 103 ms 235344 KB Output is correct
15 Correct 98 ms 235092 KB Output is correct
16 Correct 103 ms 235088 KB Output is correct
17 Correct 104 ms 235088 KB Output is correct
18 Correct 96 ms 235092 KB Output is correct
19 Correct 86 ms 235092 KB Output is correct
20 Correct 85 ms 235088 KB Output is correct
21 Correct 108 ms 235088 KB Output is correct
22 Correct 109 ms 235180 KB Output is correct
23 Correct 103 ms 235088 KB Output is correct
24 Correct 97 ms 235212 KB Output is correct
25 Correct 102 ms 235092 KB Output is correct
26 Correct 105 ms 235092 KB Output is correct
27 Correct 101 ms 235152 KB Output is correct
28 Correct 114 ms 235200 KB Output is correct
29 Correct 116 ms 235172 KB Output is correct
30 Correct 109 ms 235160 KB Output is correct
31 Correct 111 ms 235092 KB Output is correct
32 Correct 98 ms 235092 KB Output is correct
33 Correct 97 ms 235088 KB Output is correct
34 Correct 85 ms 235252 KB Output is correct
35 Correct 106 ms 235088 KB Output is correct
36 Correct 102 ms 235088 KB Output is correct
37 Runtime error 994 ms 1035192 KB Execution killed with signal 11
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 898 ms 1035344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 115 ms 235092 KB Output is correct
2 Correct 128 ms 235216 KB Output is correct
3 Correct 143 ms 235088 KB Output is correct
4 Correct 102 ms 235088 KB Output is correct
5 Execution timed out 2081 ms 242384 KB Time limit exceeded
6 Halted 0 ms 0 KB -