Submission #992357

# Submission time Handle Problem Language Result Execution time Memory
992357 2024-06-04T10:07:36 Z MarwenElarbi Sky Walking (IOI19_walk) C++17
10 / 100
1151 ms 642656 KB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define pb push_back
const int nax=4e6;
vector<pair<int,int>> adj[nax];
vector<long long> dis(nax);
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();
    int k=l.size();
    int cnt=n;
    vector<pair<int,pair<int,int>>> tab(k);
    for (int i = 0; i < k; ++i)
    {
        tab[i]={y[i],{l[i],r[i]}};
    }
    sort(tab.begin(),tab.end());
    map<int,pair<int,int>> mp;
    for (int i = 0; i < n; ++i)
    {
        mp[x[i]]={i,0};
    }
    for (int i = 0; i < k; ++i)
    {
        for (int j = tab[i].se.fi; j <= tab[i].se.se; ++j)
        {
            if(tab[i].fi<=h[j]){
                adj[cnt].pb({mp[x[j]].fi,tab[i].fi-mp[x[j]].se});
                adj[mp[x[j]].fi].pb({cnt,tab[i].fi-mp[x[j]].se});
                mp[x[j]]={cnt,tab[i].fi};
            }
            if(j>tab[i].se.fi){
                adj[cnt].pb({cnt-1,x[j]-x[j-1]});
                adj[cnt-1].pb({cnt,x[j]-x[j-1]});
            }
            cnt++;
        }
    }
    for (int i = 0; i < cnt; ++i)
    {
        dis[i]=1e18;
    }
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> pq;
    pq.push({0,s});
    dis[s]=0;
    //cout <<"hey"<<endl;
    //int t=5;
    while(!pq.empty()){
        //cout <<t<<endl;
        //if(t==0) break;
        //t--;
        ll d=pq.top().fi;
        ll x=pq.top().se;
        //cout <<x<<" "<<d<<endl;
        pq.pop();
        if(x==g){
            return d;
        }
        if(dis[x]!=d) continue;
        for(auto u:adj[x]){
            //cout <<"n "<<u.fi<<endl;
            ll newd=u.se+d;
            //cout <<u.se<<endl;
            if(newd>=dis[u.fi]) continue;
            dis[u.fi]=newd;
            pq.push({newd,u.fi});
        }
    }
    return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 21 ms 125532 KB Output is correct
2 Correct 20 ms 125532 KB Output is correct
3 Correct 19 ms 125532 KB Output is correct
4 Correct 20 ms 125528 KB Output is correct
5 Correct 20 ms 125532 KB Output is correct
6 Correct 21 ms 125532 KB Output is correct
7 Correct 20 ms 125696 KB Output is correct
8 Correct 20 ms 125532 KB Output is correct
9 Correct 20 ms 125668 KB Output is correct
10 Correct 19 ms 125532 KB Output is correct
11 Correct 20 ms 125688 KB Output is correct
12 Correct 20 ms 125532 KB Output is correct
13 Correct 21 ms 125532 KB Output is correct
14 Correct 20 ms 125672 KB Output is correct
15 Correct 20 ms 125528 KB Output is correct
16 Correct 22 ms 125532 KB Output is correct
17 Correct 22 ms 125584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 125532 KB Output is correct
2 Correct 20 ms 125448 KB Output is correct
3 Correct 377 ms 166108 KB Output is correct
4 Correct 641 ms 175444 KB Output is correct
5 Runtime error 702 ms 543316 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 66 ms 133456 KB Output is correct
2 Runtime error 1151 ms 642656 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 66 ms 133456 KB Output is correct
2 Runtime error 1151 ms 642656 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 125532 KB Output is correct
2 Correct 20 ms 125532 KB Output is correct
3 Correct 19 ms 125532 KB Output is correct
4 Correct 20 ms 125528 KB Output is correct
5 Correct 20 ms 125532 KB Output is correct
6 Correct 21 ms 125532 KB Output is correct
7 Correct 20 ms 125696 KB Output is correct
8 Correct 20 ms 125532 KB Output is correct
9 Correct 20 ms 125668 KB Output is correct
10 Correct 19 ms 125532 KB Output is correct
11 Correct 20 ms 125688 KB Output is correct
12 Correct 20 ms 125532 KB Output is correct
13 Correct 21 ms 125532 KB Output is correct
14 Correct 20 ms 125672 KB Output is correct
15 Correct 20 ms 125528 KB Output is correct
16 Correct 22 ms 125532 KB Output is correct
17 Correct 22 ms 125584 KB Output is correct
18 Correct 20 ms 125532 KB Output is correct
19 Correct 20 ms 125448 KB Output is correct
20 Correct 377 ms 166108 KB Output is correct
21 Correct 641 ms 175444 KB Output is correct
22 Runtime error 702 ms 543316 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -