#include <bits/stdc++.h>
using namespace std;
const int M = 1e5+5;
vector<array<int, 3>> E;
vector<int> node[M];
void clear();
int n, m;
void init(int _n, int _m, vector<int> U, vector<int> V, vector<int> W) {
n = _n, m = _m;
for (int i = 0; i < m; i++) E.push_back({U[i], V[i], W[i]});
sort(E.begin(), E.end(), [](array<int, 3> a, array<int, 3> b){return a[2] < b[2];});
}
int mn[M], vis[M], p[M], d[M];
void dfs(int s, int P) {
vis[s] = true;
d[s] = d[P]+1;
p[s] = P;
vector<int> c;
mn[s] = INT_MAX;
for (int i:node[s]) {
if (!vis[i]) dfs(i, s), c.push_back(i);
else if (i != P) mn[s] = d[i];
}
for (int i:c) mn[s] = min(mn[s], mn[i]);
}
void clear() {
for (int i = 0; i < n; i++) {
vis[i] = mn[i] = p[i] = d[i] = 0;
node[i].clear();
}
}
bool check(int a, int b, int X) {
clear();
for (auto [A, B, C]:E) {
if (C > X) break;
node[A].push_back(B);
node[B].push_back(A);
}
dfs(a, a);
int mxD = 0;
int x = p[b];
if (!vis[b]) return 0;
while (x != a) mxD = max(mxD, (int)node[x].size()), x = p[x];
return mxD > 2 || mn[b] == 1;
}
int solve(int a, int b) {
int x = 0, p2 = (1<<30);
while (p2 /= 2) {
if (!check(a, b, x+p2)) x += p2;
} return x+1;
}
int getMinimumFuelCapacity(int X, int Y) {
int x = solve(X, Y);
if (x > 1e9) return -1;
return x;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2656 KB |
Output is correct |
4 |
Correct |
6 ms |
2644 KB |
Output is correct |
5 |
Correct |
9 ms |
2868 KB |
Output is correct |
6 |
Correct |
11 ms |
2800 KB |
Output is correct |
7 |
Correct |
11 ms |
2772 KB |
Output is correct |
8 |
Correct |
9 ms |
2796 KB |
Output is correct |
9 |
Correct |
935 ms |
20828 KB |
Output is correct |
10 |
Execution timed out |
2067 ms |
23384 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Execution timed out |
2064 ms |
16616 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2656 KB |
Output is correct |
4 |
Correct |
6 ms |
2644 KB |
Output is correct |
5 |
Correct |
9 ms |
2868 KB |
Output is correct |
6 |
Correct |
11 ms |
2800 KB |
Output is correct |
7 |
Correct |
11 ms |
2772 KB |
Output is correct |
8 |
Correct |
9 ms |
2796 KB |
Output is correct |
9 |
Correct |
2 ms |
2768 KB |
Output is correct |
10 |
Correct |
7 ms |
2752 KB |
Output is correct |
11 |
Correct |
9 ms |
2772 KB |
Output is correct |
12 |
Correct |
10 ms |
2804 KB |
Output is correct |
13 |
Correct |
8 ms |
2668 KB |
Output is correct |
14 |
Correct |
9 ms |
2772 KB |
Output is correct |
15 |
Incorrect |
9 ms |
2796 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2768 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2656 KB |
Output is correct |
5 |
Correct |
6 ms |
2644 KB |
Output is correct |
6 |
Correct |
9 ms |
2868 KB |
Output is correct |
7 |
Correct |
11 ms |
2800 KB |
Output is correct |
8 |
Correct |
11 ms |
2772 KB |
Output is correct |
9 |
Correct |
9 ms |
2796 KB |
Output is correct |
10 |
Correct |
935 ms |
20828 KB |
Output is correct |
11 |
Execution timed out |
2067 ms |
23384 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2656 KB |
Output is correct |
4 |
Correct |
6 ms |
2644 KB |
Output is correct |
5 |
Correct |
9 ms |
2868 KB |
Output is correct |
6 |
Correct |
11 ms |
2800 KB |
Output is correct |
7 |
Correct |
11 ms |
2772 KB |
Output is correct |
8 |
Correct |
9 ms |
2796 KB |
Output is correct |
9 |
Correct |
935 ms |
20828 KB |
Output is correct |
10 |
Execution timed out |
2067 ms |
23384 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2768 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2656 KB |
Output is correct |
5 |
Correct |
6 ms |
2644 KB |
Output is correct |
6 |
Correct |
9 ms |
2868 KB |
Output is correct |
7 |
Correct |
11 ms |
2800 KB |
Output is correct |
8 |
Correct |
11 ms |
2772 KB |
Output is correct |
9 |
Correct |
9 ms |
2796 KB |
Output is correct |
10 |
Correct |
935 ms |
20828 KB |
Output is correct |
11 |
Execution timed out |
2067 ms |
23384 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |