Submission #1046962

# Submission time Handle Problem Language Result Execution time Memory
1046962 2024-08-07T07:00:40 Z vjudge1 Sky Walking (IOI19_walk) C++17
33 / 100
632 ms 114628 KB
#include "walk.h"
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
map<int,int>pos[100100];
vector<pair<int,int>> adj[1<<20];
int CC;
void AE(int a,int b,int c){
    adj[a].push_back({b,c});
    adj[b].push_back({a,c});
}
int whatpos(int i,int j){
    if(pos[i].count(j))
        return pos[i][j];
    pos[i][j]=++CC;
    auto it=pos[i].find(j);
    if(it!=pos[i].begin())
        AE(prev(it)->second,CC,it->first-prev(it)->first);
    if(next(it)!=pos[i].end())
        AE(next(it)->second,CC,next(it)->first-it->first);
    return CC;
}
long long dis[1<<20];
long long djik(int a,int b){
    memset(dis,9,sizeof dis);
    priority_queue<pair<long long,int>,vector<pair<long long,int>>,greater<>> pq;
    pq.push({0,a});
    dis[a]=0;
    while(pq.size()){
        auto[d,x]=pq.top();
        pq.pop();
        if(d-dis[x])continue;
        for(auto[v,w]:adj[x])
            if(dis[v]>d+w)
                pq.push({dis[v]=d+w,v});
    }
    return dis[b]<dis[0]?dis[b]:-1;
}
set<int>intersection[100100];
long long min_distance(VI x,VI h,VI l,VI r,VI y,int s,int g) {
    vector<pair<int,int>> endpts;
    int m=l.size();
    for(int i=0;i<m;i++)
        endpts.push_back({l[i],i}),
        endpts.push_back({r[i],i}),
        whatpos(l[i],y[i]),whatpos(r[i],y[i]);
    sort(endpts.begin(),endpts.end());
    set<pair<int,int>> active;
    for(auto[b,i]:endpts){
        int pos=y[i];
        if(active.lower_bound({pos,0})!=active.begin()){
            auto it=--active.lower_bound({pos,0});
            intersection[it->second].insert(b);
            whatpos(b,it->first);
        }
        if(b-l[i])active.erase({pos,i});
        else active.insert({pos,i});
    }
    for(int i=0;i<m;i++){
        intersection[i].erase(l[i]);
        intersection[i].insert(r[i]);
        int prvind=whatpos(l[i],y[i]),prvpos=x[l[i]];
        for(auto j:intersection[i])
            AE(prvind,whatpos(j,y[i]),x[j]-prvpos),
            prvind=whatpos(j,y[i]),prvpos=x[j];
    }
    return djik(whatpos(s,0),whatpos(g,0));
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 42588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 42584 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 58 ms 54588 KB Output is correct
2 Correct 632 ms 110900 KB Output is correct
3 Correct 578 ms 113088 KB Output is correct
4 Correct 508 ms 112200 KB Output is correct
5 Correct 581 ms 114628 KB Output is correct
6 Correct 545 ms 109596 KB Output is correct
7 Correct 200 ms 77904 KB Output is correct
8 Correct 125 ms 72384 KB Output is correct
9 Correct 526 ms 104644 KB Output is correct
10 Correct 253 ms 77252 KB Output is correct
11 Correct 11 ms 44124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 54588 KB Output is correct
2 Correct 632 ms 110900 KB Output is correct
3 Correct 578 ms 113088 KB Output is correct
4 Correct 508 ms 112200 KB Output is correct
5 Correct 581 ms 114628 KB Output is correct
6 Correct 545 ms 109596 KB Output is correct
7 Correct 200 ms 77904 KB Output is correct
8 Correct 125 ms 72384 KB Output is correct
9 Correct 526 ms 104644 KB Output is correct
10 Correct 253 ms 77252 KB Output is correct
11 Correct 11 ms 44124 KB Output is correct
12 Correct 557 ms 113304 KB Output is correct
13 Correct 418 ms 110528 KB Output is correct
14 Correct 568 ms 114384 KB Output is correct
15 Correct 375 ms 102848 KB Output is correct
16 Correct 370 ms 99216 KB Output is correct
17 Correct 415 ms 111044 KB Output is correct
18 Correct 384 ms 102852 KB Output is correct
19 Correct 377 ms 99460 KB Output is correct
20 Correct 210 ms 76996 KB Output is correct
21 Correct 20 ms 46624 KB Output is correct
22 Correct 303 ms 97216 KB Output is correct
23 Correct 255 ms 94400 KB Output is correct
24 Correct 166 ms 80192 KB Output is correct
25 Correct 231 ms 89540 KB Output is correct
26 Correct 115 ms 71104 KB Output is correct
27 Correct 569 ms 114368 KB Output is correct
28 Correct 373 ms 110148 KB Output is correct
29 Correct 547 ms 108576 KB Output is correct
30 Correct 214 ms 78024 KB Output is correct
31 Correct 516 ms 104492 KB Output is correct
32 Correct 190 ms 75456 KB Output is correct
33 Correct 188 ms 74264 KB Output is correct
34 Correct 283 ms 79612 KB Output is correct
35 Correct 247 ms 82188 KB Output is correct
36 Correct 164 ms 76640 KB Output is correct
37 Correct 132 ms 73840 KB Output is correct
38 Correct 125 ms 71440 KB Output is correct
39 Correct 295 ms 82884 KB Output is correct
40 Correct 153 ms 73308 KB Output is correct
41 Correct 146 ms 73776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 42588 KB Output isn't correct
2 Halted 0 ms 0 KB -