# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1043205 | 2024-08-04T04:50:37 Z | model_code | Circle Passing (EGOI24_circlepassing) | C++17 | 1530 ms | 1048576 KB |
#include <bits/stdc++.h> using namespace std; int n ,m ,q; vector <vector <int>> adj; vector <int> bfs(int u){ queue <int> q; q.push(u); vector <int> dist(n+n ,-1); dist[u] = 0; while(!q.empty()){ auto w = q.front(); q.pop(); for(int&o : adj[w]) if(dist[o] == -1){ dist[o] = dist[w] + 1; q.push(o); } } return dist; } int main() { scanf("%d%d%d",&n,&m,&q); adj.resize(n+n); for(int i = 0; i < n+n; i++){ adj[i].push_back(i+1 < n+n? i+1 : 0); adj[i].push_back(i > 0? i-1 : n+n-1); } for(int a ,i = 0; i < m; i++){ scanf("%d",&a); adj[a].push_back(a+n); adj[a+n].push_back(a); } vector <vector <int>> dist(n+n); for(int i = 0; i < n+n; i++) dist[i] = bfs(i); while(q--){ int x ,y; scanf("%d%d",&x,&y); printf("%d\n",dist[x][y]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Correct | 3 ms | 348 KB | Output is correct |
3 | Correct | 3 ms | 604 KB | Output is correct |
4 | Correct | 26 ms | 16256 KB | Output is correct |
5 | Runtime error | 1530 ms | 1048576 KB | Execution killed with signal 9 |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 16172 KB | Output is correct |
2 | Correct | 4 ms | 2148 KB | Output is correct |
3 | Correct | 6 ms | 2856 KB | Output is correct |
4 | Correct | 0 ms | 356 KB | Output is correct |
5 | Correct | 0 ms | 360 KB | Output is correct |
6 | Correct | 1 ms | 616 KB | Output is correct |
7 | Correct | 2 ms | 1896 KB | Output is correct |
8 | Correct | 22 ms | 16136 KB | Output is correct |
9 | Correct | 23 ms | 16272 KB | Output is correct |
10 | Correct | 22 ms | 16224 KB | Output is correct |
11 | Correct | 23 ms | 16232 KB | Output is correct |
12 | Correct | 22 ms | 16224 KB | Output is correct |
13 | Correct | 22 ms | 16252 KB | Output is correct |
14 | Correct | 33 ms | 16164 KB | Output is correct |
15 | Correct | 23 ms | 16052 KB | Output is correct |
16 | Correct | 0 ms | 352 KB | Output is correct |
17 | Correct | 0 ms | 352 KB | Output is correct |
18 | Correct | 0 ms | 360 KB | Output is correct |
19 | Correct | 0 ms | 360 KB | Output is correct |
20 | Correct | 0 ms | 352 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 16172 KB | Output is correct |
2 | Correct | 4 ms | 2148 KB | Output is correct |
3 | Correct | 6 ms | 2856 KB | Output is correct |
4 | Correct | 0 ms | 356 KB | Output is correct |
5 | Correct | 0 ms | 360 KB | Output is correct |
6 | Correct | 1 ms | 616 KB | Output is correct |
7 | Correct | 2 ms | 1896 KB | Output is correct |
8 | Correct | 22 ms | 16136 KB | Output is correct |
9 | Correct | 23 ms | 16272 KB | Output is correct |
10 | Correct | 22 ms | 16224 KB | Output is correct |
11 | Correct | 23 ms | 16232 KB | Output is correct |
12 | Correct | 22 ms | 16224 KB | Output is correct |
13 | Correct | 22 ms | 16252 KB | Output is correct |
14 | Correct | 33 ms | 16164 KB | Output is correct |
15 | Correct | 23 ms | 16052 KB | Output is correct |
16 | Correct | 0 ms | 352 KB | Output is correct |
17 | Correct | 0 ms | 352 KB | Output is correct |
18 | Correct | 0 ms | 360 KB | Output is correct |
19 | Correct | 0 ms | 360 KB | Output is correct |
20 | Correct | 0 ms | 352 KB | Output is correct |
21 | Correct | 24 ms | 16124 KB | Output is correct |
22 | Correct | 3 ms | 2152 KB | Output is correct |
23 | Correct | 4 ms | 2812 KB | Output is correct |
24 | Correct | 0 ms | 448 KB | Output is correct |
25 | Correct | 0 ms | 360 KB | Output is correct |
26 | Correct | 1 ms | 616 KB | Output is correct |
27 | Correct | 3 ms | 1904 KB | Output is correct |
28 | Correct | 22 ms | 16224 KB | Output is correct |
29 | Correct | 25 ms | 16220 KB | Output is correct |
30 | Correct | 23 ms | 16176 KB | Output is correct |
31 | Correct | 21 ms | 16092 KB | Output is correct |
32 | Correct | 37 ms | 16212 KB | Output is correct |
33 | Correct | 24 ms | 16212 KB | Output is correct |
34 | Correct | 25 ms | 16220 KB | Output is correct |
35 | Correct | 26 ms | 16096 KB | Output is correct |
36 | Correct | 0 ms | 348 KB | Output is correct |
37 | Runtime error | 721 ms | 1048576 KB | Execution killed with signal 9 |
38 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 600 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Correct | 3 ms | 348 KB | Output is correct |
3 | Correct | 3 ms | 604 KB | Output is correct |
4 | Correct | 26 ms | 16256 KB | Output is correct |
5 | Runtime error | 1530 ms | 1048576 KB | Execution killed with signal 9 |
6 | Halted | 0 ms | 0 KB | - |