Submission #932225

# Submission time Handle Problem Language Result Execution time Memory
932225 2024-02-23T05:49:15 Z salmon Sky Walking (IOI19_walk) C++14
0 / 100
47 ms 19780 KB
#include "walk.h"
#include <bits/stdc++.h>
using namespace std;

map<int,pair<int,int>> sky[100100];
map<int,long long int> d[100100];


priority_queue<pair<long long int, pair<int,int>>,vector<pair<long long int, pair<int,int>>>,greater<pair<long long int, pair<int,int>>>> pq;

long long min_distance(vector<int> x, vector<int> h, vector<int> l, vector<int> r, vector<int> y, int s, int g) {

    int N = x.size();

    for(int i = 0; i < N; i++){
        l.push_back(i);
        r.push_back(i);
        y.push_back(0);
    }

    int M = l.size();

    for(int i = 0; i < M; i++){
        for(int j = l[i]; j <= r[i]; j++){
            if(y[i] <= h[j]){
                if(sky[j].find(y[i]) != sky[j].end()){
                    sky[j][y[i]].first = min(sky[j][y[i]].first,l[i]);
                    sky[j][y[i]].second = max(sky[j][y[i]].second,r[i]);
                }
                else{
                    sky[j][y[i]] = make_pair(l[i],r[i]);
                }
            }
        }
    }

    pq.push({0,{s,0}});

    while(!pq.empty()){
        pair<long long int, pair<int,int>> iii = pq.top();
        pq.pop();
        pair<int,int> ii = iii.second;


        if(d[ii.first].find(ii.second) != d[ii.first].end()){
            continue;
        }

        d[ii.first][ii.second] = iii.first;

        auto it = sky[ii.first].find(ii.second);

        advance(it,1);

        if(it != sky[ii.first].end()){
            pq.push({iii.first + it -> first - ii.second, {ii.first, it -> first}});
        }

        advance(it,-1);

        if(it != sky[ii.first].begin()){
            advance(it,-1);
            pq.push({iii.first + ii.second - it -> first, {ii.first, it -> first}});
        }

        if(sky[ii.first][ii.second].first != ii.first){
            pq.push({iii.first + x[ii.second] - x[ii.second - 1], {ii.first - 1, ii.second}});
        }

        if(sky[ii.first][ii.second].second != ii.first){
            pq.push({iii.first + x[ii.second + 1] - x[ii.second], {ii.first + 1, ii.second}});
        }
    }




	return d[g][0];
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 9816 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 9816 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 19780 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 19780 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 9816 KB Output isn't correct
2 Halted 0 ms 0 KB -