Submission #698088

# Submission time Handle Problem Language Result Execution time Memory
698088 2023-02-12T10:01:08 Z qwerasdfzxcl Roller Coaster Railroad (IOI16_railroad) C++17
0 / 100
182 ms 12972 KB
#include "railroad.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
pair<int, int> a[200200];
int n, chk[200200];

long long plan_roller_coaster(std::vector<int> S, std::vector<int> T) {
    n = S.size();
    priority_queue<pair<int, int>> pq1, pq2;
    for (int i=1;i<=n;i++){
        a[i] = {S[i-1], T[i-1]};
        pq1.emplace(a[i].first, i);
        pq2.emplace(a[i].second, i);
        chk[i] = 1;
    }

    int cnt = n;
    while(cnt > 1){
        while(!pq1.empty() && !chk[pq1.top().second]) pq1.pop();
        while(!pq2.empty() && !chk[pq2.top().second]) pq2.pop();

        auto [e, i] = pq2.top(); pq2.pop();
        auto [s, j] = pq1.top();
        if (i==j){
            auto p = pq1.top(); pq1.pop();
            while(!pq1.empty() && !chk[pq1.top().second]) pq1.pop();

            auto [ss, jj] = pq1.top(); pq1.pop();
            s = ss, j = jj;
            pq1.push(p);
        }
        else pq1.pop();

        if (s < e) return 1e18;
        a[i] = {a[i].first, a[j].second};
        chk[j] = 0;

        pq1.emplace(a[i].first, i);
        pq2.emplace(a[i].second, i);

        cnt--;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB n = 2
2 Correct 1 ms 212 KB n = 2
3 Correct 0 ms 320 KB n = 2
4 Correct 0 ms 212 KB n = 2
5 Correct 0 ms 316 KB n = 2
6 Incorrect 0 ms 212 KB answer is not correct: 1000000000000000000 instead of 523688153
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB n = 2
2 Correct 1 ms 212 KB n = 2
3 Correct 0 ms 320 KB n = 2
4 Correct 0 ms 212 KB n = 2
5 Correct 0 ms 316 KB n = 2
6 Incorrect 0 ms 212 KB answer is not correct: 1000000000000000000 instead of 523688153
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 182 ms 9144 KB n = 199999
2 Correct 64 ms 12972 KB n = 199991
3 Correct 64 ms 12968 KB n = 199993
4 Correct 127 ms 10052 KB n = 152076
5 Correct 81 ms 6396 KB n = 93249
6 Incorrect 51 ms 11812 KB answer is not correct: 1 instead of 0
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB n = 2
2 Correct 1 ms 212 KB n = 2
3 Correct 0 ms 320 KB n = 2
4 Correct 0 ms 212 KB n = 2
5 Correct 0 ms 316 KB n = 2
6 Incorrect 0 ms 212 KB answer is not correct: 1000000000000000000 instead of 523688153
7 Halted 0 ms 0 KB -