Submission #578316

#TimeUsernameProblemLanguageResultExecution timeMemory
578316Dan4LifeCrocodile's Underground City (IOI11_crocodile)C++17
46 / 100
3 ms3156 KiB
#include "crocodile.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(s) (int)s.size() #define fi first #define se second #define pii pair<int,int> vector<pair<int,int>> adj[100010]; int n, m, dis[100010]; set<int> good; bool vis[100010]; int dfs(int s, int p){ multiset<int> S; S.clear(); if(good.count(s)) return dis[s]; if(sz(adj[s])==1) return 1000000000; //S.insert() for(auto u : adj[s]){ if(u.fi==p) continue; S.insert(dfs(u.fi,s)); } S.erase(S.begin()); return *S.begin(); } void dijkstra(int s){ for(int i = 0; i <= 100000; i++) dis[i]=1000000000; dis[s] = 0; priority_queue<pii,vector<pii>,greater<pii>> pq; pq.push({0,s}); while(!pq.empty()){ int a = pq.top().se; pq.pop(); if(vis[a]) continue; vis[a] = 1; for(auto u : adj[a]){ int b = u.fi, w = u.se; if(dis[b]>dis[a]+w){ dis[b] = dis[a]+w; pq.push({dis[b],b}); } } } } int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { n = N, m = M; for(int i = 0; i < n; i++){ int a = R[i][0], b = R[i][1], c = L[i]; adj[a].pb({b,c}), adj[b].pb({a,c}); } for(int i = 0; i < K; i++) good.insert(P[i]); dijkstra(0); return dfs(0,-1); }

Compilation message (stderr)

crocodile.cpp: In function 'void dijkstra(int)':
crocodile.cpp:33:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   33 |         if(vis[a]) continue; vis[a] = 1;
      |         ^~
crocodile.cpp:33:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   33 |         if(vis[a]) continue; vis[a] = 1;
      |                              ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...