Submission #985323

#TimeUsernameProblemLanguageResultExecution timeMemory
985323doducanhCrocodile's Underground City (IOI11_crocodile)C++14
100 / 100
409 ms91724 KiB
#include "crocodile.h" #include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define all(x) x.begin(),x.end(); using ll=long long; const ll INF=1LL<<60; using pll=pair<ll,ll>; inline void srt(array<ll,3> &arr){ arr[1]=min(arr[1],arr[2]); if(arr[0]>arr[1]){ swap(arr[0],arr[1]); } } int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){ vector<array<ll,3>> order(N,{INF,INF,INF}); priority_queue<pll,vector<pll>,greater<pll>> vert; vector<ll> dist(N,INF); rep(i,K){ dist[P[i]]=0; order[P[i]]={0,0,0}; vert.push(pll(0,P[i])); } vector<vector<pll>> gr(N); rep(i,M){ gr[R[i][0]].emplace_back(pll(R[i][1],L[i])); gr[R[i][1]].emplace_back(pll(R[i][0],L[i])); } while(!vert.empty()){ int pos; ll dis; tie(dis,pos)=vert.top(); vert.pop(); if(dist[pos]!=dis)continue; for(auto &[t,l]:gr[pos]){ order[t][2]=dis+l; srt(order[t]); if(dist[t]>order[t][1]){ dist[t]=order[t][1]; vert.push(pll(dist[t],t)); } } } return dist[0]; }

Compilation message (stderr)

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:36:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   36 |         for(auto &[t,l]:gr[pos]){
      |                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...