답안 #992360

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
992360 2024-06-04T10:09:23 Z MarwenElarbi Sky Walking (IOI19_walk) C++17
10 / 100
1537 ms 801360 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=5e6;
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;
}

/*int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n, m;
    assert(2 == scanf("%d%d", &n, &m));
    vector<int> x(n), h(n);
    for (int i = 0; i < n; i++)
        assert(2 == scanf("%d%d", &x[i], &h[i]));
    vector<int> l(m), r(m), y(m);
    for (int i = 0; i < m; i++)
        assert(3 == scanf("%d%d%d", &l[i], &r[i], &y[i]));
    int s, g;
    assert(2 == scanf("%d%d", &s, &g));
    fclose(stdin);

    long long result = min_distance(x, h, l, r, y, s, g);

    printf("%lld\n", result);
    fclose(stdout);
    return 0;
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 156764 KB Output is correct
2 Correct 25 ms 156812 KB Output is correct
3 Correct 26 ms 156968 KB Output is correct
4 Correct 25 ms 156752 KB Output is correct
5 Correct 26 ms 157020 KB Output is correct
6 Correct 24 ms 157016 KB Output is correct
7 Correct 24 ms 156896 KB Output is correct
8 Correct 22 ms 157020 KB Output is correct
9 Correct 26 ms 156900 KB Output is correct
10 Correct 25 ms 157008 KB Output is correct
11 Correct 25 ms 157020 KB Output is correct
12 Correct 26 ms 157016 KB Output is correct
13 Correct 23 ms 157016 KB Output is correct
14 Correct 30 ms 157020 KB Output is correct
15 Correct 24 ms 156976 KB Output is correct
16 Correct 23 ms 156760 KB Output is correct
17 Correct 31 ms 156892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 156760 KB Output is correct
2 Correct 22 ms 156764 KB Output is correct
3 Correct 405 ms 197484 KB Output is correct
4 Correct 704 ms 206584 KB Output is correct
5 Runtime error 811 ms 671168 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 164592 KB Output is correct
2 Runtime error 1537 ms 801360 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 164592 KB Output is correct
2 Runtime error 1537 ms 801360 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 156764 KB Output is correct
2 Correct 25 ms 156812 KB Output is correct
3 Correct 26 ms 156968 KB Output is correct
4 Correct 25 ms 156752 KB Output is correct
5 Correct 26 ms 157020 KB Output is correct
6 Correct 24 ms 157016 KB Output is correct
7 Correct 24 ms 156896 KB Output is correct
8 Correct 22 ms 157020 KB Output is correct
9 Correct 26 ms 156900 KB Output is correct
10 Correct 25 ms 157008 KB Output is correct
11 Correct 25 ms 157020 KB Output is correct
12 Correct 26 ms 157016 KB Output is correct
13 Correct 23 ms 157016 KB Output is correct
14 Correct 30 ms 157020 KB Output is correct
15 Correct 24 ms 156976 KB Output is correct
16 Correct 23 ms 156760 KB Output is correct
17 Correct 31 ms 156892 KB Output is correct
18 Correct 25 ms 156760 KB Output is correct
19 Correct 22 ms 156764 KB Output is correct
20 Correct 405 ms 197484 KB Output is correct
21 Correct 704 ms 206584 KB Output is correct
22 Runtime error 811 ms 671168 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -