#include <swap.h>
#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<pair<int, int>>> adj;
vector<bool> visited;
bool cycle = false;
int gas = 0;
void dfs(int s, int v)
{
if (visited[s]) return;
visited[s] = true;
for (auto u: adj[s])
{
if (visited[u.first] && u.first != v) cycle = true;
gas = max(gas, u.second);
dfs(u.first, s);
}
}
void init(int n1, int m1, std::vector<int> v, std::vector<int> u, std::vector<int> w) {
n = n1;
m = m1;
adj.resize(n+1);
visited.resize(n+1);
for (int i=0; i<m; i++)
{
adj[v[i]].push_back({u[i], w[i]});
adj[u[i]].push_back({v[i], w[i]});
}
}
int getMinimumFuelCapacity(int x, int y){
dfs(1, 0);
return (cycle ? gas : -1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
500 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
368 KB |
Output is correct |
7 |
Correct |
1 ms |
408 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
31 ms |
8640 KB |
Output is correct |
10 |
Correct |
36 ms |
10732 KB |
Output is correct |
11 |
Correct |
38 ms |
9720 KB |
Output is correct |
12 |
Correct |
46 ms |
10164 KB |
Output is correct |
13 |
Correct |
51 ms |
11436 KB |
Output is correct |
14 |
Correct |
37 ms |
8136 KB |
Output is correct |
15 |
Correct |
99 ms |
13248 KB |
Output is correct |
16 |
Correct |
96 ms |
12036 KB |
Output is correct |
17 |
Correct |
99 ms |
13144 KB |
Output is correct |
18 |
Correct |
91 ms |
13764 KB |
Output is correct |
19 |
Correct |
45 ms |
5720 KB |
Output is correct |
20 |
Correct |
95 ms |
15540 KB |
Output is correct |
21 |
Correct |
88 ms |
15288 KB |
Output is correct |
22 |
Correct |
123 ms |
16060 KB |
Output is correct |
23 |
Correct |
99 ms |
16056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
68 ms |
10240 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
500 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
368 KB |
Output is correct |
7 |
Correct |
1 ms |
408 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
500 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
368 KB |
Output is correct |
7 |
Correct |
1 ms |
408 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
31 ms |
8640 KB |
Output is correct |
10 |
Correct |
36 ms |
10732 KB |
Output is correct |
11 |
Correct |
38 ms |
9720 KB |
Output is correct |
12 |
Correct |
46 ms |
10164 KB |
Output is correct |
13 |
Correct |
51 ms |
11436 KB |
Output is correct |
14 |
Correct |
37 ms |
8136 KB |
Output is correct |
15 |
Correct |
99 ms |
13248 KB |
Output is correct |
16 |
Correct |
96 ms |
12036 KB |
Output is correct |
17 |
Correct |
99 ms |
13144 KB |
Output is correct |
18 |
Correct |
91 ms |
13764 KB |
Output is correct |
19 |
Incorrect |
68 ms |
10240 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |