# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
387743 | ismoilov | Race (IOI11_race) | C++14 | 3051 ms | 12328 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 "race.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(), (x).end()
#define fp(a,i,c) for(ll (a) = (i); (a) < (c); (a)++)
#define fpp(a,i,c) for(ll (a) = (i); (a) <= (c); (a)++)
#define fv(c) for(int (a) = (1); (a) <= (c); (a)++)
#define fz(c) for(int (a) = (0); (a) < (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--)
#define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
#define pb push_back
#define in insert
#define ss second
#define ff first
vector <pair<ll, ll>> v[200001];
ll a[200001], b[200001];
ll kk, mn = 1e9;
void dfs(ll x)
{
for(auto it : v[x]){
if(it.first != x){
a[it.first] = a[x]+it.second;
b[it.first] = b[x]+1;
if(a[it.first] == kk)
mn = min(mn, b[it.first]);
dfs(it.first);
}
}
}
int best_path(int n, int k, int h[][2], int l[])
{
kk = k;
fp(i,1,n)
v[h[i][0]].pb({h[i][1], l[i]});
fp(i,0,n)
{
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
dfs(i);
}
mn = (mn == 1e9 ? -1 : mn);
return mn;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |