Submission #973769

# Submission time Handle Problem Language Result Execution time Memory
973769 2024-05-02T10:48:29 Z Circling Event Hopping (BOI22_events) C++17
0 / 100
419 ms 199056 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, dist[5000][5000], endloc[5000];
pair<int64_t, pair<bool, int>> endpoints[10000];
map<int64_t, int> currdists;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin >> n >> q;
    for (int i = 0; i < n; i++){
        cin >> b >> e;
        endpoints[2 * i] = {b, {0, i}};
        endpoints[2 * i + 1] = {e, {1, i}};
        for (int j = 0; j < n; j++) dist[i][j] = - (int) (i != j);
    }
    sort(endpoints, endpoints + 2 * n);
    for (int i = 0; i < 2 * n; i++) if (endpoints[i].second.first) endloc[endpoints[i].second.second] = i;
    for (int i = 0; i < n; i++){
        currdists = {{0, 1}};
        for (int j = endloc[i] - 1; j > -1; j--){
            if (endpoints[j].second.first){
                dist[endpoints[j].second.second][i] = 1 + (*currdists.begin()).first;
                currdists[dist[endpoints[j].second.second][i]]++;
            } else{
                currdists[dist[endpoints[j].second.second][i]]--;
                if (currdists[dist[endpoints[j].second.second][i]] < 1) currdists.erase(dist[endpoints[j].second.second][i]);
            }
        }
    }
    while (q--){
        cin >> b >> e;
        b--;
        e--;
        if (b == e) cout << "0\n";
        else if (endpoints[endloc[e]].first == endpoints[endloc[b]].first) cout << "1\n";
        else{
            if (endpoints[endloc[e]].first < endpoints[endloc[b]].first) cout << "impossible\n";
            else if (dist[b][e] > -1) cout << dist[b][e] << '\n';
            else cout << "impossible\n";
        }
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 419 ms 199056 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -