# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
604336 | 2022-07-25T04:19:15 Z | Plurm | Event Hopping (BOI22_events) | C++11 | 1500 ms | 99484 KB |
#include <bits/stdc++.h> using namespace std; int dist[5005][5005]; int main() { memset(dist, 0x3F, sizeof(dist)); int n, q; scanf("%d%d", &n, &q); vector<pair<int, int>> events; for (int i = 1; i <= n; i++) { int s, e; scanf("%d%d", &s, &e); events.push_back({s, e}); } queue<int> pq; for (int i = 0; i < n; i++) { dist[i][i] = 0; pq.push(i); while (!pq.empty()) { int u = pq.front(); pq.pop(); for (int v = 0; v < n; v++) { if (u != v && events[v].first <= events[u].second && events[u].second <= events[v].second && dist[i][v] > dist[i][u] + 1) { dist[i][v] = dist[i][u] + 1; pq.push(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("%d\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 | 48 ms | 98248 KB | Output is correct |
2 | Execution timed out | 1601 ms | 99484 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 41 ms | 98304 KB | Output is correct |
2 | Correct | 45 ms | 98312 KB | Output is correct |
3 | Execution timed out | 1605 ms | 98232 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 41 ms | 98304 KB | Output is correct |
2 | Correct | 45 ms | 98312 KB | Output is correct |
3 | Execution timed out | 1605 ms | 98232 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 41 ms | 98304 KB | Output is correct |
2 | Correct | 45 ms | 98312 KB | Output is correct |
3 | Execution timed out | 1605 ms | 98232 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1581 ms | 99424 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 98248 KB | Output is correct |
2 | Execution timed out | 1601 ms | 99484 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |