답안 #738088

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
738088 2023-05-08T07:07:38 Z DAleksa Event Hopping (BOI22_events) C++17
10 / 100
1500 ms 30672 KB
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 5010;
vector<int> g[N];
int n, q;
int l[N], r[N];
int dist[N];
bool mark[N];
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> q;
    for(int i = 0; i < n; i++) cin >> l[i] >> r[i];
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if(l[j] <= r[i] && r[i] <= r[j]) g[i].push_back(j);
    while(q--) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        for(int i = 0; i < n; i++) {
            dist[i] = 1e9;
            mark[i] = false;
        }
        dist[x] = 0;
        queue<int> q;
        q.push(x);
        while(!q.empty()) {
            int u = q.front();
            q.pop();
            mark[u] = true;
            for(int v : g[u]) {
                if(mark[v]) continue;
                q.push(v);
                mark[v]=1;
                dist[v] = min(dist[v], dist[u] + 1);
            }
        }
        if(dist[y] == 1e9) cout << "impossible\n";
        else cout << dist[y] << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Runtime error 7 ms 724 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 6 ms 488 KB Output is correct
4 Correct 6 ms 492 KB Output is correct
5 Correct 5 ms 468 KB Output is correct
6 Correct 12 ms 1284 KB Output is correct
7 Correct 32 ms 2004 KB Output is correct
8 Correct 29 ms 3148 KB Output is correct
9 Correct 170 ms 4516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 6 ms 488 KB Output is correct
4 Correct 6 ms 492 KB Output is correct
5 Correct 5 ms 468 KB Output is correct
6 Correct 12 ms 1284 KB Output is correct
7 Correct 32 ms 2004 KB Output is correct
8 Correct 29 ms 3148 KB Output is correct
9 Correct 170 ms 4516 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 7 ms 520 KB Output is correct
13 Correct 5 ms 468 KB Output is correct
14 Correct 6 ms 452 KB Output is correct
15 Correct 12 ms 1188 KB Output is correct
16 Correct 26 ms 2100 KB Output is correct
17 Correct 32 ms 3156 KB Output is correct
18 Correct 151 ms 4488 KB Output is correct
19 Execution timed out 1577 ms 30672 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 6 ms 488 KB Output is correct
4 Correct 6 ms 492 KB Output is correct
5 Correct 5 ms 468 KB Output is correct
6 Correct 12 ms 1284 KB Output is correct
7 Correct 32 ms 2004 KB Output is correct
8 Correct 29 ms 3148 KB Output is correct
9 Correct 170 ms 4516 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 7 ms 468 KB Output is correct
13 Correct 6 ms 468 KB Output is correct
14 Correct 6 ms 468 KB Output is correct
15 Correct 11 ms 1224 KB Output is correct
16 Correct 27 ms 2004 KB Output is correct
17 Correct 29 ms 3156 KB Output is correct
18 Correct 143 ms 4492 KB Output is correct
19 Runtime error 8 ms 1612 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Runtime error 7 ms 724 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -