# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
604356 | 2022-07-25T04:35:14 Z | Plurm | Event Hopping (BOI22_events) | C++11 | 1500 ms | 104756 KB |
#include <bits/stdc++.h> using namespace std; vector<int> g[100005]; short dist[5005][5005]; short fastqueue[5000005]; short hidx = 0; short tidx = 0; int main() { memset(dist, 0x3F, sizeof(dist)); int n, q; scanf("%d%d", &n, &q); vector<pair<int, int>> events; int k = sqrt(n); for (int i = 1; i <= n; i++) { int s, e; scanf("%d%d", &s, &e); events.push_back({s, e}); } for (int i = 0; i < n; i++) { vector<int> tmp; for (int j = 0; j < n; j++) { if (i == j) continue; if (events[j].first <= events[i].second && events[i].second <= events[j].second) { g[i].push_back(j); } } } for (int i = 0; i < n; i++) { dist[i][i] = 0; fastqueue[tidx++] = i; while (hidx != tidx) { int u = fastqueue[hidx++]; for (int v : g[u]) { if (dist[i][v] > dist[i][u] + 1) { dist[i][v] = dist[i][u] + 1; fastqueue[tidx++] = v; } } } } for (int i = 0; i < q; i++) { int s, e; scanf("%d%d", &s, &e); if (dist[s - 1][e - 1] > n) printf("impossible\n"); else printf("%hd\n", dist[s - 1][e - 1]); // can e be reached by s?, if yes, what is the shortest path? } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 51668 KB | Output is correct |
2 | Execution timed out | 1589 ms | 52768 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 51668 KB | Output is correct |
2 | Correct | 19 ms | 51684 KB | Output is correct |
3 | Runtime error | 66 ms | 104756 KB | Execution killed with signal 11 |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 51668 KB | Output is correct |
2 | Correct | 19 ms | 51684 KB | Output is correct |
3 | Runtime error | 66 ms | 104756 KB | Execution killed with signal 11 |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 51668 KB | Output is correct |
2 | Correct | 19 ms | 51684 KB | Output is correct |
3 | Runtime error | 66 ms | 104756 KB | Execution killed with signal 11 |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1577 ms | 52804 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 51668 KB | Output is correct |
2 | Execution timed out | 1589 ms | 52768 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |