# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
735882 | tigar | Crocodile's Underground City (IOI11_crocodile) | C++14 | 2 ms | 2644 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 <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
typedef long long ll;
ll INF=LONG_MAX;
vector<pair<ll, ll> >graff[100010];
bool izlaz[100010], check[100010];
int T[100010];
void dfs(int v)
{
if(check[v])return;
check[v]=true;
if(izlaz[v]){T[v]=0; return;}
ll m1=INF, m2=INF;
for(int i=0; i<graff[v].size(); i++)
{
dfs(graff[v][i].first);
ll xx=T[graff[v][i].first]+graff[v][i].second;
if(xx<m1){m2=m1; m1=xx;}
else if(xx>=m1 and xx<=m2){m2=xx;}
}
T[v]=m2;
return;
}
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[])
{
for(int i=0; i<m; i++)
{
graff[r[i][0]].push_back({r[i][1], l[i]});
graff[r[i][1]].push_back({r[i][0], l[i]});
}
for(int i=0; i<k; i++)izlaz[p[i]]=true;
for(int i=0; i<n; i++)T[i]=INF;
dfs(0);
return T[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... |