# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
813476 | annabeth9680 | Crocodile's Underground City (IOI11_crocodile) | C++17 | 392 ms | 53532 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |