#include "swap.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int M = 2e5 + 5;
const int MAXA = 1e9 + 7;
int n, m;
array<int, 3> edge[M];
vector <int> a[N];
int ma = 0;
bool vis[N];
void init(int N, int M, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
n = N; m = M;
for(int i = 0; i < m; ++i){
edge[i] = {U[i], V[i], W[i]};
ma = max(ma, W[i]);
//a[U[i]].push_back({V[i], W[i]});
//a[V[i]].push_back({U[i], W[i]});
}
}
bool dfs(int u, int par, int Y){
vis[u] = true;
if (u == Y) return false;
for(int i : a[u]){
if (i == par) continue;
if (vis[i]) return true;
bool g = dfs(i, u, Y);
if (g) return true;
}
return false;
}
bool f(int mid, int X, int Y){
for(int i = 0; i < n; ++i) a[i].clear(), vis[i] = false;
for(int i = 0; i < m; ++i){
if (edge[i][2] <= mid) {
a[edge[i][0]].push_back(edge[i][1]);
a[edge[i][1]].push_back(edge[i][0]);
}
}
return dfs(X, -1, Y);
}
int getMinimumFuelCapacity(int X, int Y) {
int l = 0, r = MAXA;
while (l + 1 < r){
int mid = (l + r) >> 1;
if (f(mid, X, Y)) r = mid;
else l = mid;
}
if (r == MAXA) r = -1;
return r;
}
# |
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 |
2672 KB |
Output is correct |
4 |
Correct |
3 ms |
2644 KB |
Output is correct |
5 |
Correct |
4 ms |
2772 KB |
Output is correct |
6 |
Correct |
5 ms |
2772 KB |
Output is correct |
7 |
Correct |
5 ms |
2680 KB |
Output is correct |
8 |
Correct |
5 ms |
2772 KB |
Output is correct |
9 |
Correct |
297 ms |
11372 KB |
Output is correct |
10 |
Correct |
815 ms |
14624 KB |
Output is correct |
11 |
Correct |
1161 ms |
14448 KB |
Output is correct |
12 |
Correct |
1137 ms |
15068 KB |
Output is correct |
13 |
Correct |
1403 ms |
14736 KB |
Output is correct |
14 |
Execution timed out |
2080 ms |
13136 KB |
Time limit exceeded |
15 |
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 |
2019 ms |
12096 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 |
2672 KB |
Output is correct |
4 |
Correct |
3 ms |
2644 KB |
Output is correct |
5 |
Correct |
4 ms |
2772 KB |
Output is correct |
6 |
Correct |
5 ms |
2772 KB |
Output is correct |
7 |
Correct |
5 ms |
2680 KB |
Output is correct |
8 |
Correct |
5 ms |
2772 KB |
Output is correct |
9 |
Incorrect |
2 ms |
2644 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2644 KB |
Output isn't correct |
2 |
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 |
2672 KB |
Output is correct |
4 |
Correct |
3 ms |
2644 KB |
Output is correct |
5 |
Correct |
4 ms |
2772 KB |
Output is correct |
6 |
Correct |
5 ms |
2772 KB |
Output is correct |
7 |
Correct |
5 ms |
2680 KB |
Output is correct |
8 |
Correct |
5 ms |
2772 KB |
Output is correct |
9 |
Correct |
297 ms |
11372 KB |
Output is correct |
10 |
Correct |
815 ms |
14624 KB |
Output is correct |
11 |
Correct |
1161 ms |
14448 KB |
Output is correct |
12 |
Correct |
1137 ms |
15068 KB |
Output is correct |
13 |
Correct |
1403 ms |
14736 KB |
Output is correct |
14 |
Execution timed out |
2080 ms |
13136 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |