Submission #714212

# Submission time Handle Problem Language Result Execution time Memory
714212 2023-03-24T06:36:11 Z vjudge1 Event Hopping (BOI22_events) C++17
10 / 100
1500 ms 30612 KB
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>>g;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    g.resize(n + 1);
    vector<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';
//    }
    while(q--){
        int u, v;
        cin >> u >> v;
        queue<int>q;
        q.push(u);
        vector<int>dist(n + 1, -1);
        dist[u] = 0;
        while(!q.empty()){
            int cur = q.front();
            q.pop();
            for(int v : g[cur]){
                if(dist[v] == -1){
                    dist[v] = dist[cur] + 1;
                    q.push(v);
                }
            }
        }
        if(dist[v] == -1)cout << "impossible\n";
        else cout << dist[v] << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Execution timed out 1554 ms 5940 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 8 ms 340 KB Output is correct
4 Correct 7 ms 332 KB Output is correct
5 Correct 7 ms 324 KB Output is correct
6 Correct 9 ms 1108 KB Output is correct
7 Correct 19 ms 1992 KB Output is correct
8 Correct 20 ms 3056 KB Output is correct
9 Correct 84 ms 4380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 8 ms 340 KB Output is correct
4 Correct 7 ms 332 KB Output is correct
5 Correct 7 ms 324 KB Output is correct
6 Correct 9 ms 1108 KB Output is correct
7 Correct 19 ms 1992 KB Output is correct
8 Correct 20 ms 3056 KB Output is correct
9 Correct 84 ms 4380 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 7 ms 384 KB Output is correct
13 Correct 6 ms 340 KB Output is correct
14 Correct 7 ms 328 KB Output is correct
15 Correct 10 ms 1108 KB Output is correct
16 Correct 22 ms 1980 KB Output is correct
17 Correct 21 ms 3028 KB Output is correct
18 Correct 81 ms 4384 KB Output is correct
19 Execution timed out 1596 ms 30612 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 8 ms 340 KB Output is correct
4 Correct 7 ms 332 KB Output is correct
5 Correct 7 ms 324 KB Output is correct
6 Correct 9 ms 1108 KB Output is correct
7 Correct 19 ms 1992 KB Output is correct
8 Correct 20 ms 3056 KB Output is correct
9 Correct 84 ms 4380 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 340 KB Output is correct
13 Correct 6 ms 340 KB Output is correct
14 Correct 6 ms 324 KB Output is correct
15 Correct 9 ms 1188 KB Output is correct
16 Correct 18 ms 1876 KB Output is correct
17 Correct 19 ms 3056 KB Output is correct
18 Correct 84 ms 4396 KB Output is correct
19 Execution timed out 1570 ms 5544 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1564 ms 5760 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Execution timed out 1554 ms 5940 KB Time limit exceeded
3 Halted 0 ms 0 KB -