# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
319914 | knon0501 | 악어의 지하 도시 (IOI11_crocodile) | C++14 | 1040 ms | 64840 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;
int n;
vector<pair<int,int>> a[100001];
int b[100001];
int bb[100001];
int chk[100001];
int visit[100001];
int deg[100001];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
n=N;
int i,j;
for(i=0 ; i<M ; i++){
int u=R[i][0];
int v=R[i][1];
a[u].push_back({v,L[i]});
a[v].push_back({u,L[i]});
}
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> Q;
for(i=0 ; i<K ; i++){
Q.push({0,P[i]});
}
while(!Q.empty()){
int v=Q.top().second;
long long w=Q.top().first;
Q.pop();
if(visit[v])continue;
visit[v]=1;
for(auto k: a[v]){
deg[k.first]++;
long long d=w+k.second;
if(d<=b[k.first] || deg[k.first]==1 ){
bb[k.first]=b[k.first];
b[k.first]=d;
}
else if(d<=bb[k.first] || deg[k.first]==2)
bb[k.first]=d;
if(deg[k.first]>=2)
Q.push({bb[k.first],k.first});
}
}
return bb[0];
}
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... |