Submission #387743

#TimeUsernameProblemLanguageResultExecution timeMemory
387743ismoilovRace (IOI11_race)C++14
9 / 100
3051 ms12328 KiB
#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)

race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:10:26: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fp(a,i,c) for(ll (a) = (i); (a) < (c); (a)++)
      |                          ^
race.cpp:38:2: note: in expansion of macro 'fp'
   38 |  fp(i,1,n)
      |  ^~
race.cpp:10:26: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fp(a,i,c) for(ll (a) = (i); (a) < (c); (a)++)
      |                          ^
race.cpp:40:2: note: in expansion of macro 'fp'
   40 |  fp(i,0,n)
      |  ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...