Submission #980445

#TimeUsernameProblemLanguageResultExecution timeMemory
980445NexusCyberland (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const ll N=1e6+9,M=2e18+9,mod=1e9+7; ll vis[N],dis0[N],dish[N],nd; priority_queue<pair<ll,ll>>q; vector<pair<ll,ll>>v[N]; double solve(int n, int m, int k, int h, vector<int> x, vector<int>y, vector<int> c, vector<int> arr) { for(ll i=0;i<n;++i)v[i].clear(); for(ll i=0;i<m;++i) { v[x[i]].push_back({c[i],y[i]}); v[y[i]].push_back({c[i],x[i]}); } for(ll i=0;i<n;++i)dis0[i]=M,dish[i]=M; dis0[0]=0,dish[h]=0; q.push({0,0}); for(ll i=0;i<n;++i)vis[i]=0; while(q.size()) { nd=q.top().second; q.pop(); if(vis[nd])continue; vis[nd]=1; if(nd==h)break; for(auto i:v[nd]) { if(dis0[nd]+i.first<dis0[i.second]) { dis0[i.second]=dis0[nd]+i.first; q.push({-dis0[i.second],i.second}); } } } while(q.size())q.pop(); q.push({0,h}); for(ll i=0;i<n;++i)vis[i]=0; while(q.size()) { nd=q.top().second; q.pop(); if(vis[nd])continue; vis[nd]=1; for(auto i:v[nd]) { if(dish[nd]+i.first<dish[i.second]) { dish[i.second]=dish[nd]+i.first; q.push({-dish[i.second],i.second}); } } } ll ans=dis[h]; for(ll i=0;i<n;++i) { if(max(dis0[i],dish[i])==M)continue; //cout<<i<<' '<<dis0[i]<<' '<<dish[i]<<'\n'; if(!arr[i])ans=min(ans,dish[i]); else ans=min(ans,dis0[i]+dish[i]); } if(ans==M)ans=-1; return ans; } /* int main() { ios::sync_with_stdio(0); //cin.tie(0);cout.tie(0); int T; cin>>T; while (T--){ int n,m,K,H; cin>>n>>m>>K>>H; vector<int> x(m); vector<int> y(m); vector<int> c(m); vector<int> arr(n); for (int i=0;i<n;i++)cin>>arr[i]; for (int i=0;i<m;i++) cin>>x[i]>>y[i]>>c[i]; cout<<solve(n, m, K, H, x, y, c, arr)<<'\n'; } } */

Compilation message (stderr)

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:67:12: error: 'dis' was not declared in this scope; did you mean 'dish'?
   67 |     ll ans=dis[h];
      |            ^~~
      |            dish