# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
989661 |
2024-05-28T13:35:06 Z |
mindiyak |
Race (IOI11_race) |
C++14 |
|
3000 ms |
16900 KB |
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<int, int> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<ld> vd;
typedef vector<long> vl;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fst first
#define nl endl
#define sec second
#define lb lower_bound
#define ub upper_bound
#define aint(x) x.begin(), x.end()
#define raint(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000007;
#include "race.h"
vvpi paths(2e5+5);
int ans = 1e8;
bool solved = false;
void dfs(int pos,int prev,int cost,int K,int path){
if(path > ans)return;
if(cost > K)return;
if(cost == K){
ans = min(ans,path);
solved = true;
return;
}
for(auto a:paths[pos]){
if(a.fst == prev)continue;
dfs(a.fst,pos,cost+a.sec,K,path+1);
}
}
int best_path(int N, int K, int H[][2], int L[])
{
ans = 1e8;
paths = vvpi(2e5+5);
solved = false;
FOR(i,0,N-1){
paths[H[i][0]].pb({H[i][1],L[i]});
paths[H[i][1]].pb({H[i][0],L[i]});
}
FOR(i,0,N){
dfs(i,-1,0,K,0);
}
if(solved){
return ans;
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
11864 KB |
Output is correct |
2 |
Correct |
3 ms |
11868 KB |
Output is correct |
3 |
Correct |
2 ms |
11868 KB |
Output is correct |
4 |
Correct |
3 ms |
11864 KB |
Output is correct |
5 |
Correct |
3 ms |
11868 KB |
Output is correct |
6 |
Correct |
3 ms |
11868 KB |
Output is correct |
7 |
Correct |
4 ms |
11868 KB |
Output is correct |
8 |
Correct |
4 ms |
11776 KB |
Output is correct |
9 |
Correct |
4 ms |
11868 KB |
Output is correct |
10 |
Correct |
3 ms |
11868 KB |
Output is correct |
11 |
Correct |
3 ms |
11868 KB |
Output is correct |
12 |
Correct |
3 ms |
11868 KB |
Output is correct |
13 |
Correct |
3 ms |
11868 KB |
Output is correct |
14 |
Correct |
3 ms |
11868 KB |
Output is correct |
15 |
Correct |
3 ms |
11868 KB |
Output is correct |
16 |
Correct |
3 ms |
11864 KB |
Output is correct |
17 |
Correct |
3 ms |
11868 KB |
Output is correct |
18 |
Correct |
3 ms |
11868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
11864 KB |
Output is correct |
2 |
Correct |
3 ms |
11868 KB |
Output is correct |
3 |
Correct |
2 ms |
11868 KB |
Output is correct |
4 |
Correct |
3 ms |
11864 KB |
Output is correct |
5 |
Correct |
3 ms |
11868 KB |
Output is correct |
6 |
Correct |
3 ms |
11868 KB |
Output is correct |
7 |
Correct |
4 ms |
11868 KB |
Output is correct |
8 |
Correct |
4 ms |
11776 KB |
Output is correct |
9 |
Correct |
4 ms |
11868 KB |
Output is correct |
10 |
Correct |
3 ms |
11868 KB |
Output is correct |
11 |
Correct |
3 ms |
11868 KB |
Output is correct |
12 |
Correct |
3 ms |
11868 KB |
Output is correct |
13 |
Correct |
3 ms |
11868 KB |
Output is correct |
14 |
Correct |
3 ms |
11868 KB |
Output is correct |
15 |
Correct |
3 ms |
11868 KB |
Output is correct |
16 |
Correct |
3 ms |
11864 KB |
Output is correct |
17 |
Correct |
3 ms |
11868 KB |
Output is correct |
18 |
Correct |
3 ms |
11868 KB |
Output is correct |
19 |
Correct |
3 ms |
11868 KB |
Output is correct |
20 |
Correct |
3 ms |
11808 KB |
Output is correct |
21 |
Correct |
8 ms |
11868 KB |
Output is correct |
22 |
Correct |
3 ms |
11868 KB |
Output is correct |
23 |
Correct |
3 ms |
11864 KB |
Output is correct |
24 |
Correct |
3 ms |
11696 KB |
Output is correct |
25 |
Correct |
8 ms |
11868 KB |
Output is correct |
26 |
Correct |
3 ms |
11868 KB |
Output is correct |
27 |
Correct |
3 ms |
11868 KB |
Output is correct |
28 |
Correct |
4 ms |
11868 KB |
Output is correct |
29 |
Correct |
6 ms |
11868 KB |
Output is correct |
30 |
Correct |
6 ms |
11868 KB |
Output is correct |
31 |
Correct |
7 ms |
11868 KB |
Output is correct |
32 |
Correct |
9 ms |
11868 KB |
Output is correct |
33 |
Correct |
8 ms |
11868 KB |
Output is correct |
34 |
Correct |
3 ms |
11868 KB |
Output is correct |
35 |
Correct |
4 ms |
11868 KB |
Output is correct |
36 |
Correct |
3 ms |
11672 KB |
Output is correct |
37 |
Correct |
8 ms |
11868 KB |
Output is correct |
38 |
Correct |
9 ms |
11868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
11864 KB |
Output is correct |
2 |
Correct |
3 ms |
11868 KB |
Output is correct |
3 |
Correct |
2 ms |
11868 KB |
Output is correct |
4 |
Correct |
3 ms |
11864 KB |
Output is correct |
5 |
Correct |
3 ms |
11868 KB |
Output is correct |
6 |
Correct |
3 ms |
11868 KB |
Output is correct |
7 |
Correct |
4 ms |
11868 KB |
Output is correct |
8 |
Correct |
4 ms |
11776 KB |
Output is correct |
9 |
Correct |
4 ms |
11868 KB |
Output is correct |
10 |
Correct |
3 ms |
11868 KB |
Output is correct |
11 |
Correct |
3 ms |
11868 KB |
Output is correct |
12 |
Correct |
3 ms |
11868 KB |
Output is correct |
13 |
Correct |
3 ms |
11868 KB |
Output is correct |
14 |
Correct |
3 ms |
11868 KB |
Output is correct |
15 |
Correct |
3 ms |
11868 KB |
Output is correct |
16 |
Correct |
3 ms |
11864 KB |
Output is correct |
17 |
Correct |
3 ms |
11868 KB |
Output is correct |
18 |
Correct |
3 ms |
11868 KB |
Output is correct |
19 |
Correct |
446 ms |
13912 KB |
Output is correct |
20 |
Correct |
461 ms |
14928 KB |
Output is correct |
21 |
Correct |
642 ms |
14672 KB |
Output is correct |
22 |
Correct |
1159 ms |
13696 KB |
Output is correct |
23 |
Correct |
32 ms |
15448 KB |
Output is correct |
24 |
Correct |
40 ms |
15300 KB |
Output is correct |
25 |
Correct |
2783 ms |
15232 KB |
Output is correct |
26 |
Execution timed out |
3036 ms |
16900 KB |
Time limit exceeded |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
11864 KB |
Output is correct |
2 |
Correct |
3 ms |
11868 KB |
Output is correct |
3 |
Correct |
2 ms |
11868 KB |
Output is correct |
4 |
Correct |
3 ms |
11864 KB |
Output is correct |
5 |
Correct |
3 ms |
11868 KB |
Output is correct |
6 |
Correct |
3 ms |
11868 KB |
Output is correct |
7 |
Correct |
4 ms |
11868 KB |
Output is correct |
8 |
Correct |
4 ms |
11776 KB |
Output is correct |
9 |
Correct |
4 ms |
11868 KB |
Output is correct |
10 |
Correct |
3 ms |
11868 KB |
Output is correct |
11 |
Correct |
3 ms |
11868 KB |
Output is correct |
12 |
Correct |
3 ms |
11868 KB |
Output is correct |
13 |
Correct |
3 ms |
11868 KB |
Output is correct |
14 |
Correct |
3 ms |
11868 KB |
Output is correct |
15 |
Correct |
3 ms |
11868 KB |
Output is correct |
16 |
Correct |
3 ms |
11864 KB |
Output is correct |
17 |
Correct |
3 ms |
11868 KB |
Output is correct |
18 |
Correct |
3 ms |
11868 KB |
Output is correct |
19 |
Correct |
3 ms |
11868 KB |
Output is correct |
20 |
Correct |
3 ms |
11808 KB |
Output is correct |
21 |
Correct |
8 ms |
11868 KB |
Output is correct |
22 |
Correct |
3 ms |
11868 KB |
Output is correct |
23 |
Correct |
3 ms |
11864 KB |
Output is correct |
24 |
Correct |
3 ms |
11696 KB |
Output is correct |
25 |
Correct |
8 ms |
11868 KB |
Output is correct |
26 |
Correct |
3 ms |
11868 KB |
Output is correct |
27 |
Correct |
3 ms |
11868 KB |
Output is correct |
28 |
Correct |
4 ms |
11868 KB |
Output is correct |
29 |
Correct |
6 ms |
11868 KB |
Output is correct |
30 |
Correct |
6 ms |
11868 KB |
Output is correct |
31 |
Correct |
7 ms |
11868 KB |
Output is correct |
32 |
Correct |
9 ms |
11868 KB |
Output is correct |
33 |
Correct |
8 ms |
11868 KB |
Output is correct |
34 |
Correct |
3 ms |
11868 KB |
Output is correct |
35 |
Correct |
4 ms |
11868 KB |
Output is correct |
36 |
Correct |
3 ms |
11672 KB |
Output is correct |
37 |
Correct |
8 ms |
11868 KB |
Output is correct |
38 |
Correct |
9 ms |
11868 KB |
Output is correct |
39 |
Correct |
446 ms |
13912 KB |
Output is correct |
40 |
Correct |
461 ms |
14928 KB |
Output is correct |
41 |
Correct |
642 ms |
14672 KB |
Output is correct |
42 |
Correct |
1159 ms |
13696 KB |
Output is correct |
43 |
Correct |
32 ms |
15448 KB |
Output is correct |
44 |
Correct |
40 ms |
15300 KB |
Output is correct |
45 |
Correct |
2783 ms |
15232 KB |
Output is correct |
46 |
Execution timed out |
3036 ms |
16900 KB |
Time limit exceeded |
47 |
Halted |
0 ms |
0 KB |
- |