# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
595538 | 2022-07-13T20:01:16 Z | Sofiatpc | Event Hopping (BOI22_events) | C++14 | 1500 ms | 32816 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; int s[MAXN], e[MAXN], dist[MAXN]; vector<int> adj[MAXN]; void bfs(int S)//S eh um id { vector< int > fila; dist[S]=0; fila.push_back(S); int ptr = 0; while(ptr!=fila.size()) { int x = fila[ptr]; ptr++; for(int i = 0; i < (int)adj[x].size(); i++) { int viz=adj[x][i]; if(dist[viz]!=-1&&dist[viz]<=dist[x]+1)continue; dist[viz]=dist[x]+1; fila.push_back(viz); } } } int main() { int N,Q; cin>>N>>Q; for(int i = 1; i <= N; i++)cin>>s[i]>>e[i]; for(int i = 1; i <= N; i++) for(int j = 1; j <= N; j++) { if(i==j)continue; if(s[j]<=e[i] && e[i]<=e[j])adj[i].push_back(j); } for(int q = 1; q <= Q; q++) { int sx,ex; cin>>sx>>ex; for(int i = 1; i <= N; i++)dist[i]=-1; bfs(sx); if(dist[ex]==-1)cout<<"impossible\n"; else cout<<dist[ex]<<"\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Execution timed out | 1541 ms | 3964 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2644 KB | Output is correct |
2 | Correct | 2 ms | 2644 KB | Output is correct |
3 | Correct | 9 ms | 2644 KB | Output is correct |
4 | Correct | 7 ms | 2644 KB | Output is correct |
5 | Correct | 8 ms | 2644 KB | Output is correct |
6 | Correct | 14 ms | 3412 KB | Output is correct |
7 | Correct | 29 ms | 4224 KB | Output is correct |
8 | Correct | 31 ms | 5332 KB | Output is correct |
9 | Correct | 144 ms | 6644 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2644 KB | Output is correct |
2 | Correct | 2 ms | 2644 KB | Output is correct |
3 | Correct | 9 ms | 2644 KB | Output is correct |
4 | Correct | 7 ms | 2644 KB | Output is correct |
5 | Correct | 8 ms | 2644 KB | Output is correct |
6 | Correct | 14 ms | 3412 KB | Output is correct |
7 | Correct | 29 ms | 4224 KB | Output is correct |
8 | Correct | 31 ms | 5332 KB | Output is correct |
9 | Correct | 144 ms | 6644 KB | Output is correct |
10 | Correct | 2 ms | 2644 KB | Output is correct |
11 | Correct | 2 ms | 2644 KB | Output is correct |
12 | Correct | 10 ms | 2644 KB | Output is correct |
13 | Correct | 8 ms | 2644 KB | Output is correct |
14 | Correct | 8 ms | 2696 KB | Output is correct |
15 | Correct | 13 ms | 3412 KB | Output is correct |
16 | Correct | 27 ms | 4308 KB | Output is correct |
17 | Correct | 30 ms | 5332 KB | Output is correct |
18 | Correct | 140 ms | 6612 KB | Output is correct |
19 | Execution timed out | 1586 ms | 32816 KB | Time limit exceeded |
20 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2644 KB | Output is correct |
2 | Correct | 2 ms | 2644 KB | Output is correct |
3 | Correct | 9 ms | 2644 KB | Output is correct |
4 | Correct | 7 ms | 2644 KB | Output is correct |
5 | Correct | 8 ms | 2644 KB | Output is correct |
6 | Correct | 14 ms | 3412 KB | Output is correct |
7 | Correct | 29 ms | 4224 KB | Output is correct |
8 | Correct | 31 ms | 5332 KB | Output is correct |
9 | Correct | 144 ms | 6644 KB | Output is correct |
10 | Correct | 2 ms | 2688 KB | Output is correct |
11 | Correct | 1 ms | 2644 KB | Output is correct |
12 | Correct | 9 ms | 2644 KB | Output is correct |
13 | Correct | 8 ms | 2644 KB | Output is correct |
14 | Correct | 9 ms | 2644 KB | Output is correct |
15 | Correct | 18 ms | 3416 KB | Output is correct |
16 | Correct | 41 ms | 4224 KB | Output is correct |
17 | Correct | 39 ms | 5332 KB | Output is correct |
18 | Correct | 182 ms | 6624 KB | Output is correct |
19 | Execution timed out | 1571 ms | 4244 KB | Time limit exceeded |
20 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1560 ms | 3952 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Execution timed out | 1541 ms | 3964 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |