Submission #1051021

# Submission time Handle Problem Language Result Execution time Memory
1051021 2024-08-09T18:30:16 Z Itamar Sky Walking (IOI19_walk) C++14
0 / 100
18 ms 12008 KB
using namespace std;
#include<vector>
#include<map>
#include<set>
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pi pair<ll,ll>
#include<cmath>
#define vi vector<int>
#include<algorithm>
long long min_distance(std::vector<int> x, std::vector<int> h, std::vector<int> l, std::vector<int> r, std::vector<int> y, int s, int g) {
	int n = x.size(), m = l.size();
    if(n==1)return 0;
    vector<vi> in(2e5+2);
    vector<vi> out(2e5+2);
    map<int,ll> dp;
    multiset<int> se;
    se.insert(1e9+1);
    dp[1e9+1]=1e18;
    for(int i = 0; i < m;i++){
        dp[y[i]]=1e18;
        in[l[i]].push_back(y[i]);
        out[r[i]].push_back(y[i]);
    }
    out[0].push_back(0);
    dp[0]=0;
    se.insert(0);
    for(int i = 0; i < n; i++){
        for(int t : in[i])se.insert(t);
        for(int t : out[i]){
            if(i == n-1){
                dp[0] = min(dp[0], dp[t]+t);
            }
            se.erase(se.find(t));
        }
        for(int t : out[i]){
            auto it1 = se.lower_bound(t), it2 = se.upper_bound(t);
            it1--,it2++;
            dp[*it1] = min(dp[*it1],dp[t]+abs(*it1-t));
            dp[*it2] = min(dp[*it2],dp[t]+abs(*it2-t));
        }
        for(int t : out[i])if(se.find(t) == se.end())dp[t] = 1e18;
    }
    
    if(dp[0] == 1e18)return -1;
    return dp[0]+x[n-1]-x[0];
}
# 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 3 ms 9816 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 12008 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 12008 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 -