답안 #431890

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
431890 2021-06-17T16:46:41 Z Pichon5 Sky Walking (IOI19_walk) C++17
10 / 100
483 ms 149672 KB
#include "walk.h"
#include <bits/stdc++.h>
#define vi vector<int>
#define ll long long
#define vll vector<ll>
#define pb push_back
#define F first
#define S second
using namespace std;
const ll INF=1e18;
const int tam=1000005;
vector<pair<int,int> > G[tam];
pair<int,int> E[tam];
long long min_distance(vi x,vi h,vi l, vi r,vi y,int s,int g){
    int n=x.size();
    int curr=0;
    int entrada,salida;
    for(int i=0;i<n;i++){
        E[i]={curr,0};
        if(i==s)entrada=curr;
        if(i==g)salida=curr;
        curr++;
    }
    vector<pair<int,int> >A;//altura e indice
    for(int i=0;i<l.size();i++)A.pb({y[i],i});
    sort(A.begin(),A.end());
    for(int i=0;i<l.size();i++){
        int ind=A[i].S;
        int equis;
        int ant=-1;
        for(int j=l[ind];j<=r[ind];j++){
            if(h[j]<y[ind])continue;
            G[curr].pb({E[j].F,y[ind]-E[j].S});
            G[E[j].F].pb({curr,y[ind]-E[j].S});
            //cout<<curr<<" "<<E[j].F<<"  =  "<<y[ind]-E[j].S<<endl;
            E[j]={curr,y[ind]};
            if(ant!=-1){
                G[curr].pb({ant,x[j]-equis});
                //cout<<curr<<"  "<<ant<<"  =  "<<x[j]-equis<<endl;
                G[ant].pb({curr,x[j]-equis});
            }
            ant=curr;
            equis=x[j];
            curr++;
        }
    }
    priority_queue<pair<int,int> >q;
    vll dis(1000006,INF);
    dis[entrada]=0;
    q.push({0,entrada});
    vector<bool>vis(1000006,false);
    while(!q.empty()){
        int nodo=q.top().S;
        q.pop();
        if(vis[nodo])continue;
        vis[nodo]=1;
        for(auto it : G[nodo]){
            int to=it.F,w=it.S;
            if(dis[nodo]+w<dis[to]){
                dis[to]=dis[nodo]+w;
                q.push({-dis[to],to});
            }
        }
    }
    if(dis[salida]==INF)return -1;
    return dis[salida];
}
/*
7 7
0 8
3 7
5 9
7 7
10 6
12 6
14 9
0 1 1
0 2 6
0 6 8
2 3 1
2 6 7
3 4 2
4 6 5
1 5
*/

Compilation message

walk.cpp: In function 'long long int min_distance(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, int, int)':
walk.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i=0;i<l.size();i++)A.pb({y[i],i});
      |                 ~^~~~~~~~~
walk.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=0;i<l.size();i++){
      |                 ~^~~~~~~~~
walk.cpp:49:16: warning: 'entrada' may be used uninitialized in this function [-Wmaybe-uninitialized]
   49 |     dis[entrada]=0;
      |                ^
walk.cpp:65:18: warning: 'salida' may be used uninitialized in this function [-Wmaybe-uninitialized]
   65 |     if(dis[salida]==INF)return -1;
      |                  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 31692 KB Output is correct
2 Correct 18 ms 31692 KB Output is correct
3 Correct 20 ms 31692 KB Output is correct
4 Correct 21 ms 31672 KB Output is correct
5 Correct 19 ms 31692 KB Output is correct
6 Correct 19 ms 31712 KB Output is correct
7 Correct 21 ms 31736 KB Output is correct
8 Correct 20 ms 31744 KB Output is correct
9 Correct 19 ms 31820 KB Output is correct
10 Correct 21 ms 31716 KB Output is correct
11 Correct 18 ms 31712 KB Output is correct
12 Correct 19 ms 31692 KB Output is correct
13 Correct 18 ms 31728 KB Output is correct
14 Correct 19 ms 31700 KB Output is correct
15 Correct 20 ms 31704 KB Output is correct
16 Correct 20 ms 31692 KB Output is correct
17 Correct 22 ms 31716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 31692 KB Output is correct
2 Correct 17 ms 31720 KB Output is correct
3 Correct 419 ms 68312 KB Output is correct
4 Incorrect 483 ms 72688 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 39356 KB Output is correct
2 Runtime error 271 ms 149672 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 39356 KB Output is correct
2 Runtime error 271 ms 149672 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 31692 KB Output is correct
2 Correct 18 ms 31692 KB Output is correct
3 Correct 20 ms 31692 KB Output is correct
4 Correct 21 ms 31672 KB Output is correct
5 Correct 19 ms 31692 KB Output is correct
6 Correct 19 ms 31712 KB Output is correct
7 Correct 21 ms 31736 KB Output is correct
8 Correct 20 ms 31744 KB Output is correct
9 Correct 19 ms 31820 KB Output is correct
10 Correct 21 ms 31716 KB Output is correct
11 Correct 18 ms 31712 KB Output is correct
12 Correct 19 ms 31692 KB Output is correct
13 Correct 18 ms 31728 KB Output is correct
14 Correct 19 ms 31700 KB Output is correct
15 Correct 20 ms 31704 KB Output is correct
16 Correct 20 ms 31692 KB Output is correct
17 Correct 22 ms 31716 KB Output is correct
18 Correct 18 ms 31692 KB Output is correct
19 Correct 17 ms 31720 KB Output is correct
20 Correct 419 ms 68312 KB Output is correct
21 Incorrect 483 ms 72688 KB Output isn't correct
22 Halted 0 ms 0 KB -