# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
339078 |
2020-12-24T14:28:25 Z |
bigDuck |
Race (IOI11_race) |
C++14 |
|
3000 ms |
111724 KB |
#include "race.h"
#include<bits/stdc++.h>
using namespace std;
#define INIT ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
int n, k;
vector<pii> g[200010];
bool v[200010];
int mn[200010][101];
int res=1e9;
void dfs(int s){
v[s]=true;
mn[s][0]=1;
for(auto pr:g[s]){
int u=pr.ft, d=pr.sc;
if(!v[u]){
dfs(u);
for(int sum=0; (sum+d)<=( k ); sum++){
if( (mn[s][k-(sum+d) ]>0) && (mn[u][sum]>0) ){
res=min(res, mn[s][k-(sum+d)]+mn[u][sum]);
}
}
for(int sum=0; ( (sum+d)<=k ); sum++){
if( (mn[u][sum]>0) ){
if(mn[s][sum+d]==0){
mn[s][sum+d]=mn[u][sum]+1;
}
else{
mn[s][sum+d]=min(mn[s][sum+d], mn[u][sum]+1);
}
}
}
}
}
if(mn[s][k]>0){
res=min(res, mn[s][k]);
}
return;
}
int dfs2(int s, int l, int h){
int res=1e9;
if(l>k){
v[s]=false;
return res;
}
if(l==k){
v[s]=false;
return h;
}
v[s]=true;
for(pii pr:g[s]){
int u=pr.ft, d=pr.sc;
if(!v[u]){
res=min(dfs2(u, l+d, h+1), res);
}
}
v[s]=false;
return res;
}
int best_path(int N, int K, int H[][2], int L[])
{
n=N; k=K;
for(int i=0; i<(n-1); i++){
int u=H[i][0]+1, v=H[i][1]+1, d=L[i];
g[u].pb({v, d}); g[v].pb({u, d});
}
if( (k<=100) ){ dfs(1);}
else{
for(int i=1; i<=n; i++){
res=min(res, dfs2(i, 0, 1));
}
}
if(res==(1e9)){
return -1;
}
return res-1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
5100 KB |
Output is correct |
2 |
Correct |
4 ms |
5100 KB |
Output is correct |
3 |
Correct |
3 ms |
5100 KB |
Output is correct |
4 |
Correct |
4 ms |
5100 KB |
Output is correct |
5 |
Correct |
3 ms |
5100 KB |
Output is correct |
6 |
Correct |
3 ms |
5100 KB |
Output is correct |
7 |
Correct |
3 ms |
5100 KB |
Output is correct |
8 |
Correct |
4 ms |
5100 KB |
Output is correct |
9 |
Correct |
3 ms |
5100 KB |
Output is correct |
10 |
Correct |
3 ms |
5100 KB |
Output is correct |
11 |
Correct |
3 ms |
5100 KB |
Output is correct |
12 |
Correct |
4 ms |
5100 KB |
Output is correct |
13 |
Correct |
4 ms |
5100 KB |
Output is correct |
14 |
Correct |
4 ms |
5100 KB |
Output is correct |
15 |
Correct |
4 ms |
5100 KB |
Output is correct |
16 |
Correct |
4 ms |
5120 KB |
Output is correct |
17 |
Correct |
4 ms |
5100 KB |
Output is correct |
18 |
Correct |
4 ms |
5100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
5100 KB |
Output is correct |
2 |
Correct |
4 ms |
5100 KB |
Output is correct |
3 |
Correct |
3 ms |
5100 KB |
Output is correct |
4 |
Correct |
4 ms |
5100 KB |
Output is correct |
5 |
Correct |
3 ms |
5100 KB |
Output is correct |
6 |
Correct |
3 ms |
5100 KB |
Output is correct |
7 |
Correct |
3 ms |
5100 KB |
Output is correct |
8 |
Correct |
4 ms |
5100 KB |
Output is correct |
9 |
Correct |
3 ms |
5100 KB |
Output is correct |
10 |
Correct |
3 ms |
5100 KB |
Output is correct |
11 |
Correct |
3 ms |
5100 KB |
Output is correct |
12 |
Correct |
4 ms |
5100 KB |
Output is correct |
13 |
Correct |
4 ms |
5100 KB |
Output is correct |
14 |
Correct |
4 ms |
5100 KB |
Output is correct |
15 |
Correct |
4 ms |
5100 KB |
Output is correct |
16 |
Correct |
4 ms |
5120 KB |
Output is correct |
17 |
Correct |
4 ms |
5100 KB |
Output is correct |
18 |
Correct |
4 ms |
5100 KB |
Output is correct |
19 |
Correct |
3 ms |
5100 KB |
Output is correct |
20 |
Correct |
3 ms |
5100 KB |
Output is correct |
21 |
Correct |
19 ms |
5100 KB |
Output is correct |
22 |
Correct |
4 ms |
5100 KB |
Output is correct |
23 |
Correct |
4 ms |
5120 KB |
Output is correct |
24 |
Correct |
4 ms |
5100 KB |
Output is correct |
25 |
Correct |
19 ms |
5228 KB |
Output is correct |
26 |
Correct |
4 ms |
5100 KB |
Output is correct |
27 |
Correct |
4 ms |
5044 KB |
Output is correct |
28 |
Correct |
8 ms |
5100 KB |
Output is correct |
29 |
Correct |
13 ms |
5248 KB |
Output is correct |
30 |
Correct |
13 ms |
5100 KB |
Output is correct |
31 |
Correct |
19 ms |
5100 KB |
Output is correct |
32 |
Correct |
19 ms |
5100 KB |
Output is correct |
33 |
Correct |
16 ms |
5100 KB |
Output is correct |
34 |
Correct |
5 ms |
5100 KB |
Output is correct |
35 |
Correct |
5 ms |
5100 KB |
Output is correct |
36 |
Correct |
5 ms |
5100 KB |
Output is correct |
37 |
Correct |
12 ms |
5100 KB |
Output is correct |
38 |
Correct |
15 ms |
5100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
5100 KB |
Output is correct |
2 |
Correct |
4 ms |
5100 KB |
Output is correct |
3 |
Correct |
3 ms |
5100 KB |
Output is correct |
4 |
Correct |
4 ms |
5100 KB |
Output is correct |
5 |
Correct |
3 ms |
5100 KB |
Output is correct |
6 |
Correct |
3 ms |
5100 KB |
Output is correct |
7 |
Correct |
3 ms |
5100 KB |
Output is correct |
8 |
Correct |
4 ms |
5100 KB |
Output is correct |
9 |
Correct |
3 ms |
5100 KB |
Output is correct |
10 |
Correct |
3 ms |
5100 KB |
Output is correct |
11 |
Correct |
3 ms |
5100 KB |
Output is correct |
12 |
Correct |
4 ms |
5100 KB |
Output is correct |
13 |
Correct |
4 ms |
5100 KB |
Output is correct |
14 |
Correct |
4 ms |
5100 KB |
Output is correct |
15 |
Correct |
4 ms |
5100 KB |
Output is correct |
16 |
Correct |
4 ms |
5120 KB |
Output is correct |
17 |
Correct |
4 ms |
5100 KB |
Output is correct |
18 |
Correct |
4 ms |
5100 KB |
Output is correct |
19 |
Correct |
130 ms |
49772 KB |
Output is correct |
20 |
Correct |
129 ms |
49664 KB |
Output is correct |
21 |
Correct |
128 ms |
49644 KB |
Output is correct |
22 |
Correct |
134 ms |
49644 KB |
Output is correct |
23 |
Correct |
103 ms |
49772 KB |
Output is correct |
24 |
Correct |
100 ms |
49772 KB |
Output is correct |
25 |
Correct |
128 ms |
53868 KB |
Output is correct |
26 |
Correct |
93 ms |
58348 KB |
Output is correct |
27 |
Correct |
242 ms |
93676 KB |
Output is correct |
28 |
Correct |
242 ms |
111724 KB |
Output is correct |
29 |
Correct |
238 ms |
110316 KB |
Output is correct |
30 |
Correct |
245 ms |
93676 KB |
Output is correct |
31 |
Correct |
243 ms |
93676 KB |
Output is correct |
32 |
Correct |
289 ms |
93676 KB |
Output is correct |
33 |
Correct |
258 ms |
92780 KB |
Output is correct |
34 |
Correct |
169 ms |
92484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
5100 KB |
Output is correct |
2 |
Correct |
4 ms |
5100 KB |
Output is correct |
3 |
Correct |
3 ms |
5100 KB |
Output is correct |
4 |
Correct |
4 ms |
5100 KB |
Output is correct |
5 |
Correct |
3 ms |
5100 KB |
Output is correct |
6 |
Correct |
3 ms |
5100 KB |
Output is correct |
7 |
Correct |
3 ms |
5100 KB |
Output is correct |
8 |
Correct |
4 ms |
5100 KB |
Output is correct |
9 |
Correct |
3 ms |
5100 KB |
Output is correct |
10 |
Correct |
3 ms |
5100 KB |
Output is correct |
11 |
Correct |
3 ms |
5100 KB |
Output is correct |
12 |
Correct |
4 ms |
5100 KB |
Output is correct |
13 |
Correct |
4 ms |
5100 KB |
Output is correct |
14 |
Correct |
4 ms |
5100 KB |
Output is correct |
15 |
Correct |
4 ms |
5100 KB |
Output is correct |
16 |
Correct |
4 ms |
5120 KB |
Output is correct |
17 |
Correct |
4 ms |
5100 KB |
Output is correct |
18 |
Correct |
4 ms |
5100 KB |
Output is correct |
19 |
Correct |
3 ms |
5100 KB |
Output is correct |
20 |
Correct |
3 ms |
5100 KB |
Output is correct |
21 |
Correct |
19 ms |
5100 KB |
Output is correct |
22 |
Correct |
4 ms |
5100 KB |
Output is correct |
23 |
Correct |
4 ms |
5120 KB |
Output is correct |
24 |
Correct |
4 ms |
5100 KB |
Output is correct |
25 |
Correct |
19 ms |
5228 KB |
Output is correct |
26 |
Correct |
4 ms |
5100 KB |
Output is correct |
27 |
Correct |
4 ms |
5044 KB |
Output is correct |
28 |
Correct |
8 ms |
5100 KB |
Output is correct |
29 |
Correct |
13 ms |
5248 KB |
Output is correct |
30 |
Correct |
13 ms |
5100 KB |
Output is correct |
31 |
Correct |
19 ms |
5100 KB |
Output is correct |
32 |
Correct |
19 ms |
5100 KB |
Output is correct |
33 |
Correct |
16 ms |
5100 KB |
Output is correct |
34 |
Correct |
5 ms |
5100 KB |
Output is correct |
35 |
Correct |
5 ms |
5100 KB |
Output is correct |
36 |
Correct |
5 ms |
5100 KB |
Output is correct |
37 |
Correct |
12 ms |
5100 KB |
Output is correct |
38 |
Correct |
15 ms |
5100 KB |
Output is correct |
39 |
Correct |
130 ms |
49772 KB |
Output is correct |
40 |
Correct |
129 ms |
49664 KB |
Output is correct |
41 |
Correct |
128 ms |
49644 KB |
Output is correct |
42 |
Correct |
134 ms |
49644 KB |
Output is correct |
43 |
Correct |
103 ms |
49772 KB |
Output is correct |
44 |
Correct |
100 ms |
49772 KB |
Output is correct |
45 |
Correct |
128 ms |
53868 KB |
Output is correct |
46 |
Correct |
93 ms |
58348 KB |
Output is correct |
47 |
Correct |
242 ms |
93676 KB |
Output is correct |
48 |
Correct |
242 ms |
111724 KB |
Output is correct |
49 |
Correct |
238 ms |
110316 KB |
Output is correct |
50 |
Correct |
245 ms |
93676 KB |
Output is correct |
51 |
Correct |
243 ms |
93676 KB |
Output is correct |
52 |
Correct |
289 ms |
93676 KB |
Output is correct |
53 |
Correct |
258 ms |
92780 KB |
Output is correct |
54 |
Correct |
169 ms |
92484 KB |
Output is correct |
55 |
Correct |
244 ms |
5484 KB |
Output is correct |
56 |
Correct |
2602 ms |
5708 KB |
Output is correct |
57 |
Correct |
83 ms |
51052 KB |
Output is correct |
58 |
Execution timed out |
3086 ms |
11368 KB |
Time limit exceeded |
59 |
Halted |
0 ms |
0 KB |
- |