Submission #1093662

#TimeUsernameProblemLanguageResultExecution timeMemory
1093662AvianshCrocodile's Underground City (IOI11_crocodile)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #include "crocodile.h" using namespace std; int travel_plan(int n, int m, int edges[][2], int w[], int k, int p[]) { vector<pair<int,int>> g[n]; for(int i =0;i<m;i++){ g[edges[i][0]].push_back({edges[i][1],w[i]}); g[edges[i][1]].push_back({edges[i][0],w[i]}); } bool ex[n]; fill(ex,ex+n,0); for(int i = 0;i<k;i++){ ex[p[i]]=1; } bool vis[n]; fill(vis,vis+n,0); vis[0]=1; bool rem[n+1]; fill(rem,rem+n+1,0); priority_queue<array<int,3>,vector<array<int,3>>,greater<array<int,3>>>pq; // dist,origin,destination pq.push({0,n,0}); while(!pq.empty()){ array<int,3> a = pq.top(); pq.pop(); //cout << "popped: " << a[0] << " " << a[1] << " " << a[2] << "\n"; if(ex[a[2]]){ if(rem[a[1]]){ return a[0]; } else{ rem[a[1]]=1; continue; } } vis[a[2]]=1; for(pair<int,int>p:g[a[2]]){ if(vis[p.first]) continue; //cout << "adding to pq: " << a[0]+p.second << " " << a[2] << " " << p.first << "\n"; pq.push({a[0]+p.second,a[2],p.first}); } } assert(0); return -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...