Submission #751645

# Submission time Handle Problem Language Result Execution time Memory
751645 2023-06-01T05:26:30 Z JooDdae 버스 (JOI14_bus) C++17
0 / 100
309 ms 22972 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int INF = 1e9;

int n, m, q, in[300300];
priority_queue<array<int, 3>, vector<array<int, 3>>, greater<>> pq;
vector<array<int, 2>> v[100100];

int main(){
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> m;
    for(int i=1;i<=m;i++) {
        int a, b, c, d; cin >> a >> b >> c >> d;
        pq.push({c, i, a}), pq.push({d, -i, b});
    }

    memset(in, -1, sizeof in);

    while(!pq.empty()) {
        auto [t, id, u] = pq.top(); pq.pop();

        if(id < 0) {
            id = -id;
            if(in[id] < 0 || (!v[u].empty() && v[u].back()[1] >= in[id])) continue;
            v[u].push_back({t, in[id]});
        } else {
            if(v[u].empty()) {
                if(u == 1) in[id] = t;
                continue;
            }
            in[id] = v[u].back()[1];
        }
    }

    cin >> q;
    while(q--) {
        int x; cin >> x;

        auto it = lower_bound(v[n].begin(), v[n].end(), array<int, 2>({x, INF}));
        cout << (it == v[n].begin() ? -1 : (*prev(it))[1]) << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3836 KB Output is correct
2 Correct 23 ms 5508 KB Output is correct
3 Correct 24 ms 5364 KB Output is correct
4 Correct 4 ms 3924 KB Output is correct
5 Correct 4 ms 3924 KB Output is correct
6 Incorrect 4 ms 3908 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 261 ms 22972 KB Output is correct
2 Correct 257 ms 22872 KB Output is correct
3 Correct 249 ms 22820 KB Output is correct
4 Correct 258 ms 22904 KB Output is correct
5 Correct 288 ms 22824 KB Output is correct
6 Correct 285 ms 22920 KB Output is correct
7 Correct 265 ms 22352 KB Output is correct
8 Correct 263 ms 22680 KB Output is correct
9 Correct 284 ms 22868 KB Output is correct
10 Incorrect 283 ms 21892 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 309 ms 22832 KB Output is correct
2 Correct 278 ms 22872 KB Output is correct
3 Correct 280 ms 22820 KB Output is correct
4 Correct 279 ms 22808 KB Output is correct
5 Correct 256 ms 22860 KB Output is correct
6 Correct 294 ms 22828 KB Output is correct
7 Incorrect 272 ms 22444 KB Output isn't correct
8 Halted 0 ms 0 KB -