# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
142758 |
2019-08-10T18:56:15 Z |
eggag32 |
Race (IOI11_race) |
C++17 |
|
3000 ms |
12024 KB |
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include "race.h"
//#include "grader.cpp"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define endl '\n'
template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }
int n, k;
vector<pi> g[200005];
int vis[200005];
int ans = 1e9;
void dfs(int cur, int sum, int cnt){
vis[cur] = 1;
if(sum > k) return;
if(sum == k){
ans = min(ans, cnt);
}
for(pi u : g[cur]) if(!vis[u.fi]){
dfs(u.fi, sum + u.se, cnt + 1);
}
}
int best_path(int N, int K, int h[][2], int l[]){
k = K;
n = N;
rep(i, n){
g[h[i][0]].pb({h[i][1], l[i]});
g[h[i][1]].pb({h[i][0], l[i]});
}
rep(i, n){
memset(vis, 0, sizeof(vis));
dfs(i, 0, 0);
}
return (ans == 1e9 ? -1 : ans);
}
/*
Things to look out for:
- Integer overflows
- Array bounds
- Special cases
Be careful!
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
5880 KB |
Output is correct |
2 |
Correct |
12 ms |
5880 KB |
Output is correct |
3 |
Correct |
11 ms |
5852 KB |
Output is correct |
4 |
Correct |
11 ms |
5852 KB |
Output is correct |
5 |
Correct |
11 ms |
5880 KB |
Output is correct |
6 |
Correct |
11 ms |
5880 KB |
Output is correct |
7 |
Correct |
12 ms |
5880 KB |
Output is correct |
8 |
Correct |
11 ms |
5880 KB |
Output is correct |
9 |
Correct |
11 ms |
5752 KB |
Output is correct |
10 |
Correct |
11 ms |
5880 KB |
Output is correct |
11 |
Correct |
11 ms |
5752 KB |
Output is correct |
12 |
Correct |
11 ms |
5752 KB |
Output is correct |
13 |
Correct |
11 ms |
5884 KB |
Output is correct |
14 |
Correct |
11 ms |
5752 KB |
Output is correct |
15 |
Correct |
11 ms |
5752 KB |
Output is correct |
16 |
Correct |
11 ms |
5752 KB |
Output is correct |
17 |
Correct |
12 ms |
5860 KB |
Output is correct |
18 |
Correct |
12 ms |
5752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
5880 KB |
Output is correct |
2 |
Correct |
12 ms |
5880 KB |
Output is correct |
3 |
Correct |
11 ms |
5852 KB |
Output is correct |
4 |
Correct |
11 ms |
5852 KB |
Output is correct |
5 |
Correct |
11 ms |
5880 KB |
Output is correct |
6 |
Correct |
11 ms |
5880 KB |
Output is correct |
7 |
Correct |
12 ms |
5880 KB |
Output is correct |
8 |
Correct |
11 ms |
5880 KB |
Output is correct |
9 |
Correct |
11 ms |
5752 KB |
Output is correct |
10 |
Correct |
11 ms |
5880 KB |
Output is correct |
11 |
Correct |
11 ms |
5752 KB |
Output is correct |
12 |
Correct |
11 ms |
5752 KB |
Output is correct |
13 |
Correct |
11 ms |
5884 KB |
Output is correct |
14 |
Correct |
11 ms |
5752 KB |
Output is correct |
15 |
Correct |
11 ms |
5752 KB |
Output is correct |
16 |
Correct |
11 ms |
5752 KB |
Output is correct |
17 |
Correct |
12 ms |
5860 KB |
Output is correct |
18 |
Correct |
12 ms |
5752 KB |
Output is correct |
19 |
Correct |
7 ms |
5752 KB |
Output is correct |
20 |
Correct |
11 ms |
5880 KB |
Output is correct |
21 |
Correct |
59 ms |
5880 KB |
Output is correct |
22 |
Correct |
47 ms |
5880 KB |
Output is correct |
23 |
Correct |
47 ms |
5880 KB |
Output is correct |
24 |
Correct |
52 ms |
5880 KB |
Output is correct |
25 |
Correct |
60 ms |
5880 KB |
Output is correct |
26 |
Correct |
47 ms |
5880 KB |
Output is correct |
27 |
Correct |
47 ms |
5880 KB |
Output is correct |
28 |
Correct |
53 ms |
5852 KB |
Output is correct |
29 |
Correct |
55 ms |
5912 KB |
Output is correct |
30 |
Correct |
56 ms |
5884 KB |
Output is correct |
31 |
Correct |
61 ms |
5880 KB |
Output is correct |
32 |
Correct |
60 ms |
5880 KB |
Output is correct |
33 |
Correct |
60 ms |
5912 KB |
Output is correct |
34 |
Correct |
45 ms |
5880 KB |
Output is correct |
35 |
Correct |
45 ms |
5880 KB |
Output is correct |
36 |
Correct |
41 ms |
5880 KB |
Output is correct |
37 |
Correct |
47 ms |
6008 KB |
Output is correct |
38 |
Correct |
53 ms |
5880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
5880 KB |
Output is correct |
2 |
Correct |
12 ms |
5880 KB |
Output is correct |
3 |
Correct |
11 ms |
5852 KB |
Output is correct |
4 |
Correct |
11 ms |
5852 KB |
Output is correct |
5 |
Correct |
11 ms |
5880 KB |
Output is correct |
6 |
Correct |
11 ms |
5880 KB |
Output is correct |
7 |
Correct |
12 ms |
5880 KB |
Output is correct |
8 |
Correct |
11 ms |
5880 KB |
Output is correct |
9 |
Correct |
11 ms |
5752 KB |
Output is correct |
10 |
Correct |
11 ms |
5880 KB |
Output is correct |
11 |
Correct |
11 ms |
5752 KB |
Output is correct |
12 |
Correct |
11 ms |
5752 KB |
Output is correct |
13 |
Correct |
11 ms |
5884 KB |
Output is correct |
14 |
Correct |
11 ms |
5752 KB |
Output is correct |
15 |
Correct |
11 ms |
5752 KB |
Output is correct |
16 |
Correct |
11 ms |
5752 KB |
Output is correct |
17 |
Correct |
12 ms |
5860 KB |
Output is correct |
18 |
Correct |
12 ms |
5752 KB |
Output is correct |
19 |
Execution timed out |
3049 ms |
12024 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
5880 KB |
Output is correct |
2 |
Correct |
12 ms |
5880 KB |
Output is correct |
3 |
Correct |
11 ms |
5852 KB |
Output is correct |
4 |
Correct |
11 ms |
5852 KB |
Output is correct |
5 |
Correct |
11 ms |
5880 KB |
Output is correct |
6 |
Correct |
11 ms |
5880 KB |
Output is correct |
7 |
Correct |
12 ms |
5880 KB |
Output is correct |
8 |
Correct |
11 ms |
5880 KB |
Output is correct |
9 |
Correct |
11 ms |
5752 KB |
Output is correct |
10 |
Correct |
11 ms |
5880 KB |
Output is correct |
11 |
Correct |
11 ms |
5752 KB |
Output is correct |
12 |
Correct |
11 ms |
5752 KB |
Output is correct |
13 |
Correct |
11 ms |
5884 KB |
Output is correct |
14 |
Correct |
11 ms |
5752 KB |
Output is correct |
15 |
Correct |
11 ms |
5752 KB |
Output is correct |
16 |
Correct |
11 ms |
5752 KB |
Output is correct |
17 |
Correct |
12 ms |
5860 KB |
Output is correct |
18 |
Correct |
12 ms |
5752 KB |
Output is correct |
19 |
Correct |
7 ms |
5752 KB |
Output is correct |
20 |
Correct |
11 ms |
5880 KB |
Output is correct |
21 |
Correct |
59 ms |
5880 KB |
Output is correct |
22 |
Correct |
47 ms |
5880 KB |
Output is correct |
23 |
Correct |
47 ms |
5880 KB |
Output is correct |
24 |
Correct |
52 ms |
5880 KB |
Output is correct |
25 |
Correct |
60 ms |
5880 KB |
Output is correct |
26 |
Correct |
47 ms |
5880 KB |
Output is correct |
27 |
Correct |
47 ms |
5880 KB |
Output is correct |
28 |
Correct |
53 ms |
5852 KB |
Output is correct |
29 |
Correct |
55 ms |
5912 KB |
Output is correct |
30 |
Correct |
56 ms |
5884 KB |
Output is correct |
31 |
Correct |
61 ms |
5880 KB |
Output is correct |
32 |
Correct |
60 ms |
5880 KB |
Output is correct |
33 |
Correct |
60 ms |
5912 KB |
Output is correct |
34 |
Correct |
45 ms |
5880 KB |
Output is correct |
35 |
Correct |
45 ms |
5880 KB |
Output is correct |
36 |
Correct |
41 ms |
5880 KB |
Output is correct |
37 |
Correct |
47 ms |
6008 KB |
Output is correct |
38 |
Correct |
53 ms |
5880 KB |
Output is correct |
39 |
Execution timed out |
3049 ms |
12024 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |