# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
580309 | 2022-06-21T05:04:09 Z | 반딧불(#8355) | Event Hopping (BOI22_events) | C++17 | 1500 ms | 56724 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; struct Range{ int l, r, idx; Range(){} Range(int l, int r, int idx): l(l), r(r), idx(idx){} bool operator<(const Range &nxt)const{ return l<nxt.l; } }; struct dat{ int s, x, idx; dat(){} dat(int s, int x, int idx): s(s), x(x), idx(idx){} bool operator<(const dat &r)const{ return s<r.s; } }; int n, q; Range arr[100002]; vector<int> link[100002]; int dist[5002][5002]; void bfs(int r){ queue<pair<int, int> > que; que.push(make_pair(r, 0)); while(!que.empty()){ int x = que.front().first, d = que.front().second; que.pop(); for(auto y: link[x]){ if(dist[r][y] != 1e9) continue; dist[r][y] = d+1; que.push(make_pair(y, d+1)); } } } int main(){ scanf("%d %d", &n, &q); for(int i=1; i<=n; i++){ scanf("%d %d", &arr[i].l, &arr[i].r); arr[i].idx = i; } for(int i=1; i<=n; i++) for(int j=1; j<=n; j++){ if(i==j) continue; if(arr[j].l <= arr[i].r && arr[i].r <= arr[j].r) link[i].push_back(j); dist[i][j] = 1e9; } for(int i=1; i<=n; i++) bfs(1); while(q--){ int l, r; scanf("%d %d", &l, &r); if(dist[l][r] == 1e9) printf("impossible\n"); else printf("%d\n", dist[l][r]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2692 KB | Output is correct |
2 | Execution timed out | 1545 ms | 55200 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Correct | 1 ms | 2644 KB | Output is correct |
3 | Incorrect | 10 ms | 10580 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Correct | 1 ms | 2644 KB | Output is correct |
3 | Incorrect | 10 ms | 10580 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Correct | 1 ms | 2644 KB | Output is correct |
3 | Incorrect | 10 ms | 10580 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1575 ms | 56724 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2692 KB | Output is correct |
2 | Execution timed out | 1545 ms | 55200 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |