# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
897793 | Trumling | Crocodile's Underground City (IOI11_crocodile) | C++14 | 405 ms | 89880 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 long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';
#define INF 9999999999999999
#define MOD 1000000007
#define round fixed<<setprecision(2)<<
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
vector<vector<pair<ll,ll>>>g(N+1);
for(int i=0;i<M;i++)
{
g[R[i][0]].pb({R[i][1],L[i]});
g[R[i][1]].pb({R[i][0],L[i]});
}
priority_queue<pair<ll,ll>>pq;
vector<pair<ll,ll>>dist(N+1,{INF,INF});
for(int i=0;i<K;i++)
{
dist[P[i]]={0,0};
pq.push({0,P[i]});
}
while(!pq.empty())
{
ll curr=pq.top().S;
ll w=-pq.top().F;
pq.pop();
if(dist[curr].S<w)
continue;
for(auto x:g[curr])
{
if(dist[x.F].F> w + x.S)
{
if(dist[x.F].F!=dist[x.F].S)
pq.push({-dist[x.F].F,x.F});
swap(dist[x.F].F,dist[x.F].S);
dist[x.F].F=w + x.S;
// pq.push({-dist[x.F].F,x.F});
continue;
}
if(dist[x.F].S> w + x.S)
{
dist[x.F].S=w + x.S;
pq.push({-dist[x.F].S,x.F});
}
}
}
return (int) dist[0].S;
}
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... |