This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |