# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
29186 | kavun | Crocodile's Underground City (IOI11_crocodile) | C++14 | 896 ms | 173196 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;
typedef pair<int,int> ii;
priority_queue <ii> Q;
vector<ii> adj[150010];
int mk[150010];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
for(int i = 0; i < M; i++)
{
int v = R[i][0], u = R[i][1], l = L[i];
adj[v].push_back(make_pair(u,l));
adj[u].push_back(make_pair(v,l));
}
for(int i = 0; i < K; i++)
{
Q.push(make_pair(0,P[i]));
mk[P[i]] = 1;
}
while(!Q.empty())
{
int v = Q.top().second;
int val = -Q.top().first;
Q.pop();
if(mk[v] == 1)
{
for(int i = 0; i < adj[v].size(); i++)
Q.push(ii(-(adj[v][i].second + val),adj[v][i].first));
if(v == 0)
return val;
}
mk[v]++;
}
return -1;
}
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... |