Submission #813476

#TimeUsernameProblemLanguageResultExecution timeMemory
813476annabeth9680Crocodile's Underground City (IOI11_crocodile)C++17
100 / 100
392 ms53532 KiB
#include "crocodile.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1e5+5; vector<pair<int,int>> adj[MAXN]; vector<int> dist[MAXN]; int vis[MAXN]; int travel_plan(int N, int M, int R[][2], int L[], int K, int exits[]){ for(int i = 0;i<M;++i){ adj[R[i][0]].push_back({L[i],R[i][1]}); adj[R[i][1]].push_back({L[i],R[i][0]}); } priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq; for(int i = 0;i<K;++i){ dist[exits[i]].push_back(0); dist[exits[i]].push_back(0); vis[exits[i]]++; pq.push({0,exits[i]}); } while(!pq.empty()){ int u = pq.top().second, cdist = pq.top().first; pq.pop(); if(vis[u] >= 2) continue; vis[u]++; if(vis[u] != 2) continue; if(u == 0) return cdist; for(auto p : adj[u]){ int cur = cdist+p.first, v = p.second; if(dist[v].size() < 2){ dist[v].push_back(cur); pq.push({cur,v}); } else if(dist[v].size() == 2){ if(dist[v][0] > dist[v][1]) swap(dist[v][0],dist[v][1]); if(dist[v][1] > cur){ dist[v].pop_back(); dist[v].push_back(cur); pq.push({cur,v}); } } } } }

Compilation message (stderr)

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:12:80: warning: control reaches end of non-void function [-Wreturn-type]
   12 |     priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
      |                                                                                ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...