#include <bits/stdc++.h>
#include "swap.h"
using ll = long long;
const int maxn = 1e5 + 10;
int n;
vector<pair<ll,int>> g[maxn];
bool loop = false;
ll maxW = 0;
void dfs(int at, int p, int dep) {
if (dep==n) loop=true;
for (auto ed: g[at]) {
int to = ed.second;
if (to == p) continue;
dfs(to,at,dep+1);
}
}
void init(int N, int M, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
n=N;
for (int i=0; i<M; i++) {
g[U[i]].push_back({W[i],V[i]});
g[V[i]].push_back({W[i],U[i]});
maxW=max(maxW,1ll*W[i]);
}
dfs(0,-1,0);
}
int getMinimumFuelCapacity(int X, int Y) {
if (loop) return maxW;
return -1;
}
/*
int main() {
init(5, 6, {0, 0, 1, 1, 1, 2}, {1, 2, 2, 3, 4, 3}, {4, 4, 1, 2, 10, 3});
cout<<getMinimumFuelCapacity(1, 2)<<endl;
cout<<getMinimumFuelCapacity(2, 4)<<endl;
cout<<getMinimumFuelCapacity(0, 1)<<endl;
return 0;
}
*/
Compilation message
swap.cpp:10:1: error: 'vector' does not name a type
10 | vector<pair<ll,int>> g[maxn];
| ^~~~~~
swap.cpp: In function 'void dfs(int, int, int)':
swap.cpp:18:19: error: 'g' was not declared in this scope
18 | for (auto ed: g[at]) {
| ^
swap.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
swap.cpp:29:2: error: 'g' was not declared in this scope
29 | g[U[i]].push_back({W[i],V[i]});
| ^
swap.cpp:31:7: error: 'max' was not declared in this scope; did you mean 'std::max'?
31 | maxW=max(maxW,1ll*W[i]);
| ^~~
| std::max
In file included from /usr/include/c++/9/algorithm:62,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
from swap.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: 'std::max' declared here
3462 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~