# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
714323 | 2023-03-24T08:43:35 Z | vjudge1 | Event Hopping (BOI22_events) | C++17 | 1500 ms | 36352 KB |
#include <iostream> #include <vector> #include <queue> using namespace std; int n, q; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> q; vector<vector<int>>g(n + 1); pair<int, int>events[n + 1]; for(int i = 1;i <= n;++i){ cin >> events[i].first >> events[i].second; } for(int i = 1;i <= n;++i){ for(int j = 1;j <= n;++j){ if(i == j)continue; if(events[i].second >= events[j].first && events[i].second <= events[j].second){ g[i].push_back(j); } } } // for(int i = 1;i <= n;++i){ // cout << i << ": "; // for(int j : g[i]){ // cout << j << " "; // } // cout << '\n'; // } vector<vector<int>>dists(n + 1); bool check[n + 1]; for(int i = 1;i <= n;++i)check[i] = 0; for(int i = 0;i < q;++i){ int u, v; cin >> u >> v; if(dists[u].size() == n + 1 && dists[u][v] != -1)cout << dists[u][v] << '\n'; else if(dists[u].size() == n + 1 && dists[u][v] == -1 && check[u])cout << "impossible\n"; else{ vector<int>tempo(n + 1, -1); queue<int>que; que.push(u); check[u] = 1; tempo[u] = 0; while(!que.empty()){ int cur = que.front(); que.pop(); for(int vv : g[cur]){ if(tempo[vv] == -1){ tempo[vv] = tempo[cur] + 1; que.push(vv); } } } if(tempo[v] == -1)cout << "impossible\n"; else cout << tempo[v] << '\n'; swap(tempo, dists[u]); } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Execution timed out | 1580 ms | 3604 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 6 ms | 340 KB | Output is correct |
4 | Correct | 5 ms | 724 KB | Output is correct |
5 | Correct | 6 ms | 724 KB | Output is correct |
6 | Correct | 10 ms | 1540 KB | Output is correct |
7 | Correct | 18 ms | 2304 KB | Output is correct |
8 | Correct | 22 ms | 3404 KB | Output is correct |
9 | Correct | 8 ms | 4316 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 6 ms | 340 KB | Output is correct |
4 | Correct | 5 ms | 724 KB | Output is correct |
5 | Correct | 6 ms | 724 KB | Output is correct |
6 | Correct | 10 ms | 1540 KB | Output is correct |
7 | Correct | 18 ms | 2304 KB | Output is correct |
8 | Correct | 22 ms | 3404 KB | Output is correct |
9 | Correct | 8 ms | 4316 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 5 ms | 468 KB | Output is correct |
13 | Correct | 6 ms | 632 KB | Output is correct |
14 | Correct | 6 ms | 724 KB | Output is correct |
15 | Correct | 10 ms | 1492 KB | Output is correct |
16 | Correct | 20 ms | 2380 KB | Output is correct |
17 | Correct | 27 ms | 3412 KB | Output is correct |
18 | Correct | 8 ms | 4308 KB | Output is correct |
19 | Execution timed out | 1583 ms | 36352 KB | Time limit exceeded |
20 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 6 ms | 340 KB | Output is correct |
4 | Correct | 5 ms | 724 KB | Output is correct |
5 | Correct | 6 ms | 724 KB | Output is correct |
6 | Correct | 10 ms | 1540 KB | Output is correct |
7 | Correct | 18 ms | 2304 KB | Output is correct |
8 | Correct | 22 ms | 3404 KB | Output is correct |
9 | Correct | 8 ms | 4316 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 5 ms | 340 KB | Output is correct |
13 | Correct | 5 ms | 724 KB | Output is correct |
14 | Correct | 6 ms | 724 KB | Output is correct |
15 | Correct | 10 ms | 1540 KB | Output is correct |
16 | Correct | 20 ms | 2260 KB | Output is correct |
17 | Correct | 20 ms | 3412 KB | Output is correct |
18 | Correct | 8 ms | 4436 KB | Output is correct |
19 | Execution timed out | 1564 ms | 3712 KB | Time limit exceeded |
20 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1564 ms | 3620 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Execution timed out | 1580 ms | 3604 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |