# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1090119 |
2024-09-17T18:10:41 Z |
LilPluton |
Race (IOI11_race) |
C++14 |
|
3000 ms |
16012 KB |
#include "race.h"
#include <bits/stdc++.h>
using namespace std;
const int sz = 2e5 + 5;
int n, res;
vector<long long> dist(sz), dep(sz, 0);
vector<vector<pair<int, int>>> adj(sz);
int dij(int s, int need, int n) {
vector<long long> dist(n, LLONG_MAX);
vector<int> dep(n, INT_MAX);
priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q;
vector<int>ssss;
dist[s] = 0;
dep[s] = 0;
q.push({0, s});
while (!q.empty()) {
int v = q.top().second;
long long d_v = q.top().first;
q.pop();
if (d_v != dist[v]) {
continue;
}
if (dist[v] == need) {
ssss.push_back(dep[v]);
}
for (auto i : adj[v]) {
int u = i.first;
int weight = i.second;
if (dist[u] > dist[v] + weight) {
dist[u] = dist[v] + weight;
dep[u] = dep[v] + 1;
q.push({dist[u], u});
}
}
}
if(ssss.size() == 0)
return INT_MAX;
sort(ssss.begin(), ssss.end());
return ssss[0];
}
int best_path(int N, int K, int H[][2], int L[]) {
if (K == 1) {
return 0;
}
for (int i = 0; i < N; ++i) {
adj[H[i][0]].push_back({H[i][1], L[i]});
adj[H[i][1]].push_back({H[i][0], L[i]});
}
int res = INT_MAX;
for (int i = 0; i < N; ++i) {
int path_length = dij(i, K, N);
res = min(res, path_length);
}
return (res == INT_MAX ? -1 : res);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8280 KB |
Output is correct |
2 |
Correct |
4 ms |
8296 KB |
Output is correct |
3 |
Correct |
3 ms |
8284 KB |
Output is correct |
4 |
Correct |
4 ms |
8284 KB |
Output is correct |
5 |
Correct |
4 ms |
8284 KB |
Output is correct |
6 |
Correct |
4 ms |
8284 KB |
Output is correct |
7 |
Correct |
4 ms |
8284 KB |
Output is correct |
8 |
Correct |
3 ms |
8284 KB |
Output is correct |
9 |
Correct |
4 ms |
8136 KB |
Output is correct |
10 |
Correct |
3 ms |
8284 KB |
Output is correct |
11 |
Correct |
4 ms |
8284 KB |
Output is correct |
12 |
Correct |
3 ms |
8284 KB |
Output is correct |
13 |
Correct |
4 ms |
8284 KB |
Output is correct |
14 |
Correct |
3 ms |
8284 KB |
Output is correct |
15 |
Correct |
4 ms |
8284 KB |
Output is correct |
16 |
Correct |
4 ms |
8128 KB |
Output is correct |
17 |
Correct |
3 ms |
8284 KB |
Output is correct |
18 |
Correct |
4 ms |
8284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8280 KB |
Output is correct |
2 |
Correct |
4 ms |
8296 KB |
Output is correct |
3 |
Correct |
3 ms |
8284 KB |
Output is correct |
4 |
Correct |
4 ms |
8284 KB |
Output is correct |
5 |
Correct |
4 ms |
8284 KB |
Output is correct |
6 |
Correct |
4 ms |
8284 KB |
Output is correct |
7 |
Correct |
4 ms |
8284 KB |
Output is correct |
8 |
Correct |
3 ms |
8284 KB |
Output is correct |
9 |
Correct |
4 ms |
8136 KB |
Output is correct |
10 |
Correct |
3 ms |
8284 KB |
Output is correct |
11 |
Correct |
4 ms |
8284 KB |
Output is correct |
12 |
Correct |
3 ms |
8284 KB |
Output is correct |
13 |
Correct |
4 ms |
8284 KB |
Output is correct |
14 |
Correct |
3 ms |
8284 KB |
Output is correct |
15 |
Correct |
4 ms |
8284 KB |
Output is correct |
16 |
Correct |
4 ms |
8128 KB |
Output is correct |
17 |
Correct |
3 ms |
8284 KB |
Output is correct |
18 |
Correct |
4 ms |
8284 KB |
Output is correct |
19 |
Correct |
4 ms |
8284 KB |
Output is correct |
20 |
Correct |
4 ms |
8288 KB |
Output is correct |
21 |
Correct |
82 ms |
8284 KB |
Output is correct |
22 |
Correct |
56 ms |
8284 KB |
Output is correct |
23 |
Correct |
60 ms |
8280 KB |
Output is correct |
24 |
Correct |
69 ms |
8352 KB |
Output is correct |
25 |
Correct |
68 ms |
8284 KB |
Output is correct |
26 |
Correct |
68 ms |
8284 KB |
Output is correct |
27 |
Correct |
75 ms |
8284 KB |
Output is correct |
28 |
Correct |
75 ms |
8284 KB |
Output is correct |
29 |
Correct |
72 ms |
8280 KB |
Output is correct |
30 |
Correct |
76 ms |
8348 KB |
Output is correct |
31 |
Correct |
72 ms |
8348 KB |
Output is correct |
32 |
Correct |
72 ms |
8352 KB |
Output is correct |
33 |
Correct |
67 ms |
8280 KB |
Output is correct |
34 |
Correct |
25 ms |
8284 KB |
Output is correct |
35 |
Correct |
23 ms |
8284 KB |
Output is correct |
36 |
Correct |
19 ms |
8284 KB |
Output is correct |
37 |
Correct |
22 ms |
8284 KB |
Output is correct |
38 |
Correct |
28 ms |
8284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8280 KB |
Output is correct |
2 |
Correct |
4 ms |
8296 KB |
Output is correct |
3 |
Correct |
3 ms |
8284 KB |
Output is correct |
4 |
Correct |
4 ms |
8284 KB |
Output is correct |
5 |
Correct |
4 ms |
8284 KB |
Output is correct |
6 |
Correct |
4 ms |
8284 KB |
Output is correct |
7 |
Correct |
4 ms |
8284 KB |
Output is correct |
8 |
Correct |
3 ms |
8284 KB |
Output is correct |
9 |
Correct |
4 ms |
8136 KB |
Output is correct |
10 |
Correct |
3 ms |
8284 KB |
Output is correct |
11 |
Correct |
4 ms |
8284 KB |
Output is correct |
12 |
Correct |
3 ms |
8284 KB |
Output is correct |
13 |
Correct |
4 ms |
8284 KB |
Output is correct |
14 |
Correct |
3 ms |
8284 KB |
Output is correct |
15 |
Correct |
4 ms |
8284 KB |
Output is correct |
16 |
Correct |
4 ms |
8128 KB |
Output is correct |
17 |
Correct |
3 ms |
8284 KB |
Output is correct |
18 |
Correct |
4 ms |
8284 KB |
Output is correct |
19 |
Execution timed out |
3035 ms |
16012 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8280 KB |
Output is correct |
2 |
Correct |
4 ms |
8296 KB |
Output is correct |
3 |
Correct |
3 ms |
8284 KB |
Output is correct |
4 |
Correct |
4 ms |
8284 KB |
Output is correct |
5 |
Correct |
4 ms |
8284 KB |
Output is correct |
6 |
Correct |
4 ms |
8284 KB |
Output is correct |
7 |
Correct |
4 ms |
8284 KB |
Output is correct |
8 |
Correct |
3 ms |
8284 KB |
Output is correct |
9 |
Correct |
4 ms |
8136 KB |
Output is correct |
10 |
Correct |
3 ms |
8284 KB |
Output is correct |
11 |
Correct |
4 ms |
8284 KB |
Output is correct |
12 |
Correct |
3 ms |
8284 KB |
Output is correct |
13 |
Correct |
4 ms |
8284 KB |
Output is correct |
14 |
Correct |
3 ms |
8284 KB |
Output is correct |
15 |
Correct |
4 ms |
8284 KB |
Output is correct |
16 |
Correct |
4 ms |
8128 KB |
Output is correct |
17 |
Correct |
3 ms |
8284 KB |
Output is correct |
18 |
Correct |
4 ms |
8284 KB |
Output is correct |
19 |
Correct |
4 ms |
8284 KB |
Output is correct |
20 |
Correct |
4 ms |
8288 KB |
Output is correct |
21 |
Correct |
82 ms |
8284 KB |
Output is correct |
22 |
Correct |
56 ms |
8284 KB |
Output is correct |
23 |
Correct |
60 ms |
8280 KB |
Output is correct |
24 |
Correct |
69 ms |
8352 KB |
Output is correct |
25 |
Correct |
68 ms |
8284 KB |
Output is correct |
26 |
Correct |
68 ms |
8284 KB |
Output is correct |
27 |
Correct |
75 ms |
8284 KB |
Output is correct |
28 |
Correct |
75 ms |
8284 KB |
Output is correct |
29 |
Correct |
72 ms |
8280 KB |
Output is correct |
30 |
Correct |
76 ms |
8348 KB |
Output is correct |
31 |
Correct |
72 ms |
8348 KB |
Output is correct |
32 |
Correct |
72 ms |
8352 KB |
Output is correct |
33 |
Correct |
67 ms |
8280 KB |
Output is correct |
34 |
Correct |
25 ms |
8284 KB |
Output is correct |
35 |
Correct |
23 ms |
8284 KB |
Output is correct |
36 |
Correct |
19 ms |
8284 KB |
Output is correct |
37 |
Correct |
22 ms |
8284 KB |
Output is correct |
38 |
Correct |
28 ms |
8284 KB |
Output is correct |
39 |
Execution timed out |
3035 ms |
16012 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |