Submission #973703

# Submission time Handle Problem Language Result Execution time Memory
973703 2024-05-02T09:46:45 Z Circling Event Hopping (BOI22_events) C++17
20 / 100
106 ms 14632 KB
/*The British Royal Family and a small cadre of English Fabian Socialists, in
conjunction with the Rockefellers and the Rothchilds, are engaged in a
conspiracy to greatly reduce the population of the human race in order to head
off a Malthusian catastrophe, a catastrophe that could easily be avoided by
simply building a massive amount of nuclear power plants and a number of massive
superhighways and bridges to connect all of the world's continents. But doing
that would cut into the conspiracy's profits. So the British Royal Family
invented environmentalism and neoliberalism in order to hide the truth. And in
order to further reduce the population, the British Royal Family is also the
world's foremost drug trafficking conspiracy. And it uses its control of the IMF
to push austerity in order to kill as many people in the global south as
possible.
And also Henry Kissinger is a gay KGB agent. */
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;


int n, q, b, e, jump[18][100000], tail = 0, mind, maxd, midd, curr, inputtosort[100000];
pair<pair<int64_t, int64_t>, int> ranges[100000];


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin >> n >> q;
    for (int i = 0; i < n; i++){
        cin >> ranges[i].first.first >> ranges[i].first.second;
        ranges[i].second = i;
    }
    sort(ranges, ranges + n);
    for (int i = 0; i < n; i++){
        inputtosort[ranges[i].second] = i;
        while (ranges[tail].first.second < ranges[i].first.first){
            jump[0][tail] = i - 1;
            tail++;
        }
    }
    for (; tail < n; tail++) jump[0][tail] = n - 1;
    for (int i = 1; i < 18; i++) for (int j = 0; j < n; j++) jump[i][j] = jump[i - 1][jump[i - 1][j]];
    while (q--){
        cin >> b >> e;
        b = inputtosort[b - 1];
        e = inputtosort[e - 1];
        if (b > e || jump[17][b] < e){
            cout << "impossible\n";
            continue;
        }
        mind = 0;
        maxd = n - 1;
        while (mind != maxd){
            midd = (mind + maxd) / 2;
            curr = b;
            for (int i = 0; i < 18; i++) if ((midd >> i) % 2 == 1) curr = jump[i][curr];
            if (curr >= e) maxd = midd;
            else mind = midd + 1;
        }
        cout << mind << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Incorrect 1 ms 4440 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Incorrect 1 ms 4440 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Incorrect 1 ms 4440 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 89 ms 10752 KB Output is correct
2 Correct 90 ms 14160 KB Output is correct
3 Correct 106 ms 13804 KB Output is correct
4 Correct 39 ms 14200 KB Output is correct
5 Correct 75 ms 14632 KB Output is correct
6 Correct 89 ms 13904 KB Output is correct
7 Correct 84 ms 13932 KB Output is correct
8 Correct 71 ms 14160 KB Output is correct
9 Correct 25 ms 12116 KB Output is correct
10 Correct 87 ms 13652 KB Output is correct
11 Correct 83 ms 13392 KB Output is correct
12 Correct 86 ms 13544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -