Submission #977694

#TimeUsernameProblemLanguageResultExecution timeMemory
977694NexusCyberland (APIO23_cyberland)C++17
0 / 100
25 ms13036 KiB
#define ll long long #include <bits/stdc++.h> #include "cyberland.h" using namespace std; const ll N=1e5+9; pair<ll,ll>p; ll vis[N],a[N],g; vector<pair<ll,ll>>v[N]; vector<ll>o; priority_queue<pair<ll,ll>>q; void dfs(ll node) { if(vis[node])return; vis[node]=1; if(!a[node])o.push_back(node); for(auto i:v[node])dfs(i.second); } double solve(int n, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { vector<ll>dis(n,1e18); double ans=1e9+9; o.clear(); o.push_back(0); for(ll i=0;i<n;++i) { a[i]=arr[i]; vis[i]=0,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]}); } dfs(0); for(ll i=0;i<n;++i)vis[i]=0; dis[H]=0; q.push({H,0}); while(q.size()) { p=q.top(); g=p.second; q.pop(); if(vis[g])continue; vis[g]=1; for(auto i:v[g]) { if(dis[g]+i.first<dis[i.second]) { dis[i.second]=dis[g]+i.first; q.push({-dis[i.second],i.second}); } } } for(auto i:o)ans=min(ans,double(i)); if(ans==1e9+9)ans=-1; return ans; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...