# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
671252 | groshi | Crocodile's Underground City (IOI11_crocodile) | C++17 | 507 ms | 67236 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<iostream>
#include<vector>
#include<queue>
using namespace std;
struct wi{
vector<int> Q;
int odw=0;
int ktory=0;
}*w;
int travel_plan(int n,int m,int R[][2],int L[],int k,int P[])
{
w=new wi[n+3];
for(int i=0;i<m;i++)
{
int x=R[i][0];
int y=R[i][1];
int z=L[i];
cin>>x>>y>>z;
w[x].Q.push_back(y);
w[x].Q.push_back(z);
w[y].Q.push_back(x);
w[y].Q.push_back(z);
}
priority_queue<pair<int,int> > kolejka;
for(int i=0;i<k;i++)
{
int x=P[i];
w[x].odw=1;
for(int j=0;j<w[x].Q.size();j+=2)
{
int pom=w[x].Q[j];
kolejka.push({-w[x].Q[j+1],pom});
}
}
while(!kolejka.empty())
{
auto para=kolejka.top();
kolejka.pop();
if(w[para.second].odw)
continue;
w[para.second].ktory++;
if(w[para.second].ktory==2)
{
if(para.second==0)
return -para.first;
w[para.second].odw=1;
for(int i=0;i<w[para.second].Q.size();i+=2)
{
int pom=w[para.second].Q[i];
if(w[pom].odw)
continue;
kolejka.push({para.first-w[para.second].Q[i+1],pom});
}
}
}
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... |