답안 #1077123

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1077123 2024-08-27T01:18:14 Z HD1 Sky Walking (IOI19_walk) C++14
24 / 100
3457 ms 980480 KB
#include "walk.h"
#include<bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define sz(x) ll(x.size())
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
const ll MAX=3e6;
const ll inf=1e18;
vector<ii>gfo[MAX];
ll cur[MAX], dist[MAX];
void dikstra(ll ini){
    set<ii> q;
    q.insert({0,ini});
    dist[ini]=0;
    while(sz(q)){
        auto x=*q.begin();
        q.erase(q.begin());
        ll u=x.ss;
        ll dist_u=x.ff;
        if(dist_u!=dist[u])continue;
        for(auto y:gfo[u]){
            ll w=y.ss;
            ll v=y.ff;
            if(dist[v]>dist[u]+w){
                dist[v]=dist[u]+w;
                q.insert({dist[v], v});
            }
        }
    }
}
map< pair<ll,ll>, ll> M;
set<ll> torre;
long long min_distance(vector<int> x,vector<int> h,
    vector<int> l,vector<int> r, 
    vector<int> y, int s, int g) {
    vector<pair<int,ii>> c;
    ll m=sz(y);//numero de rascacielos
    ll n=sz(x);//numero de torres
    for(ll i=0; i<m; i++){
        c.pb({y[i],{l[i],r[i]}});// por su altura
    }
    for(ll i=0; i<n; i++){
        torre.insert(i);
    }
    sort(all(c));
    ll nod=0, nod_prev=0, mx=0, pos=0;
    for(ll i=0; i<n; i++){
        if(!M.count({x[i], 0})){
            M[{x[i],0}]=mx+1;
            mx++;
            cur[i]=0;//altura
        }
    }
    //cout<<mx<<'\n';
    vector<ll>ers;
    for(auto q:c){//rascacielo en la altura q.ff
        ll alt=q.ff;
        ll l=q.ss.ff, r=q.ss.ss;
        if(!sz(torre))continue;
        for(auto it=torre.lower_bound(l); it!=torre.end() && it!=torre.upper_bound(r); it++){
            if(alt<=h[*it]){// hay interseccion
                if(!M.count({x[*it],alt})){//creamos el nodo
                    M[{x[*it],alt}]=mx+1;
                    mx++;
                }
                nod=M[{x[*it],alt}];
                // vertical
                gfo[nod].pb({M[{x[*it], cur[*it]}],alt-cur[*it]});
                gfo[M[{x[*it], cur[*it]}]].pb({nod,alt-cur[*it]});
                cur[*it]=alt;
                if(*it==l){
                    nod_prev=nod;
                    pos=x[*it];
                    continue;
                }
                //horizontal
                gfo[nod].pb({nod_prev, x[*it]-pos});
                gfo[nod_prev].pb({nod, x[*it]-pos});
                nod_prev=nod;
                pos=x[*it];
            }
            else {
                ers.pb(*it);
            }
        }
        for(ll w:ers){
            torre.erase(torre.find(w));
        }
        ers.clear();
    }
    for(ll i=0; i<=mx; i++)dist[i]=inf;
    dikstra(M[{x[s],0}]);
    ll ans=dist[M[{x[g],0}]];
    if(ans==inf)ans=-1;
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 72532 KB Output is correct
2 Correct 35 ms 72532 KB Output is correct
3 Correct 34 ms 72372 KB Output is correct
4 Correct 33 ms 72540 KB Output is correct
5 Correct 34 ms 72540 KB Output is correct
6 Correct 34 ms 72528 KB Output is correct
7 Correct 34 ms 72540 KB Output is correct
8 Correct 36 ms 72528 KB Output is correct
9 Correct 47 ms 72440 KB Output is correct
10 Correct 34 ms 72532 KB Output is correct
11 Correct 35 ms 72540 KB Output is correct
12 Correct 31 ms 72384 KB Output is correct
13 Correct 34 ms 72332 KB Output is correct
14 Correct 32 ms 72536 KB Output is correct
15 Correct 34 ms 72528 KB Output is correct
16 Correct 33 ms 72400 KB Output is correct
17 Correct 33 ms 72532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 72536 KB Output is correct
2 Correct 35 ms 72508 KB Output is correct
3 Correct 1234 ms 182724 KB Output is correct
4 Correct 1236 ms 195956 KB Output is correct
5 Correct 781 ms 176840 KB Output is correct
6 Correct 708 ms 165116 KB Output is correct
7 Correct 803 ms 176832 KB Output is correct
8 Correct 1373 ms 212596 KB Output is correct
9 Correct 962 ms 177092 KB Output is correct
10 Correct 1624 ms 239400 KB Output is correct
11 Correct 663 ms 137144 KB Output is correct
12 Correct 485 ms 124868 KB Output is correct
13 Correct 1362 ms 224708 KB Output is correct
14 Correct 336 ms 118468 KB Output is correct
15 Correct 342 ms 120768 KB Output is correct
16 Correct 316 ms 121972 KB Output is correct
17 Correct 313 ms 119408 KB Output is correct
18 Correct 309 ms 125780 KB Output is correct
19 Correct 41 ms 74772 KB Output is correct
20 Correct 149 ms 95432 KB Output is correct
21 Correct 273 ms 120272 KB Output is correct
22 Correct 293 ms 125128 KB Output is correct
23 Correct 362 ms 131328 KB Output is correct
24 Correct 295 ms 122280 KB Output is correct
25 Correct 316 ms 120840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 106 ms 88776 KB Output is correct
2 Runtime error 3457 ms 980480 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 106 ms 88776 KB Output is correct
2 Runtime error 3457 ms 980480 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 72532 KB Output is correct
2 Correct 35 ms 72532 KB Output is correct
3 Correct 34 ms 72372 KB Output is correct
4 Correct 33 ms 72540 KB Output is correct
5 Correct 34 ms 72540 KB Output is correct
6 Correct 34 ms 72528 KB Output is correct
7 Correct 34 ms 72540 KB Output is correct
8 Correct 36 ms 72528 KB Output is correct
9 Correct 47 ms 72440 KB Output is correct
10 Correct 34 ms 72532 KB Output is correct
11 Correct 35 ms 72540 KB Output is correct
12 Correct 31 ms 72384 KB Output is correct
13 Correct 34 ms 72332 KB Output is correct
14 Correct 32 ms 72536 KB Output is correct
15 Correct 34 ms 72528 KB Output is correct
16 Correct 33 ms 72400 KB Output is correct
17 Correct 33 ms 72532 KB Output is correct
18 Correct 33 ms 72536 KB Output is correct
19 Correct 35 ms 72508 KB Output is correct
20 Correct 1234 ms 182724 KB Output is correct
21 Correct 1236 ms 195956 KB Output is correct
22 Correct 781 ms 176840 KB Output is correct
23 Correct 708 ms 165116 KB Output is correct
24 Correct 803 ms 176832 KB Output is correct
25 Correct 1373 ms 212596 KB Output is correct
26 Correct 962 ms 177092 KB Output is correct
27 Correct 1624 ms 239400 KB Output is correct
28 Correct 663 ms 137144 KB Output is correct
29 Correct 485 ms 124868 KB Output is correct
30 Correct 1362 ms 224708 KB Output is correct
31 Correct 336 ms 118468 KB Output is correct
32 Correct 342 ms 120768 KB Output is correct
33 Correct 316 ms 121972 KB Output is correct
34 Correct 313 ms 119408 KB Output is correct
35 Correct 309 ms 125780 KB Output is correct
36 Correct 41 ms 74772 KB Output is correct
37 Correct 149 ms 95432 KB Output is correct
38 Correct 273 ms 120272 KB Output is correct
39 Correct 293 ms 125128 KB Output is correct
40 Correct 362 ms 131328 KB Output is correct
41 Correct 295 ms 122280 KB Output is correct
42 Correct 316 ms 120840 KB Output is correct
43 Correct 106 ms 88776 KB Output is correct
44 Runtime error 3457 ms 980480 KB Execution killed with signal 11
45 Halted 0 ms 0 KB -