Submission #360609

#TimeUsernameProblemLanguageResultExecution timeMemory
360609juggernautSky Walking (IOI19_walk)C++14
10 / 100
4065 ms102096 KiB
#include<bits/stdc++.h> #include"walk.h" #ifndef EVAL #include"grader.cpp" #endif using namespace std; vector<int>e[100000],b[100000]; vector<pair<int,int>>adj[100000]; long long min_distance(vector<int>x,vector<int>h,vector<int>l,vector<int>r,vector<int>y,int s,int g){ map<int,int>curr; priority_queue<pair<long long,pair<int,int>>>q; map<pair<int,int>,long long>val; set<pair<int,int>>vis; for(int i=0;i<r.size();i++){ e[r[i]].push_back(y[i]); b[l[i]].push_back(y[i]); } for(int i=0;i<x.size();i++){ for(auto& to:curr){ if(to.first>h[i])break; adj[i].push_back({to.second,to.first}); adj[to.second].push_back({i,to.first}); to.second=i; } for(auto to:e[i])curr.erase(to); for(auto to:b[i])curr[to]=i; } val[{s,0}]=0; q.push({0,{s,0}}); while(!q.empty()){ auto v=q.top().second; q.pop(); if(vis.count(v))continue; vis.insert(v); for(auto to:adj[v.first]){ if(vis.count(to)||(val.count(to)&&val[to]<=val[v]+abs(v.second-to.second)+abs(x[v.first]-x[to.first])))continue; val[to]=val[v]+abs(v.second-to.second)+abs(x[v.first]-x[to.first]); q.push({-val[to],to}); } } long long ans=1e18; for(auto v:val) if(v.first.first==g)ans=min(ans,v.second+v.first.second); if(ans==1e18)ans=-1; return ans; }

Compilation message (stderr)

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:14:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for(int i=0;i<r.size();i++){
      |              ~^~~~~~~~~
walk.cpp:18:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for(int i=0;i<x.size();i++){
      |              ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...