#include "swap.h"
#include <vector>
#include <algorithm>
using namespace std;
int res = 0;
bool cycle = 0;
int n, m;
vector<int> u, v, w;
vector<int> edges;
vector<int> E[100001];
bool edgesort(int A, int B)
{
return w[A] < w[B];
}
void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
n = N; //cities
m = M; //roads
u = U;
v = V;
w = W;
for(int i = 0; i < m; i++) edges.push_back(i);
sort(edges.begin(), edges.end(), edgesort);
for(int i = 0; i < m; i++)
{
E[ u[edges[i]] ].push_back(edges[i]);
E[ v[edges[i]] ].push_back(edges[i]);
}
}
int getMinimumFuelCapacity(int X, int Y)
{
vector<int> color_index(n);
for(int i = 0; i < n; i++) color[i] = i;
vector<int> color_set[n];
for(int i = 0; i < n; i++) color_set[i].push_back(i);
vector<bool> loop(n, 0);
int c1, c2;
for(int e: edges)
{
c1 = color_index[ u[e] ];
c2 = color_index[ v[e] ];
if(c1 == c2) loop[c1] = 1;
else
{
if(c1 < c2)
{
swap(u[e], v[e]);
swap(c1, c2);
for(int h: color_set[c2])
{
color_index[h] = c1;
color_set[c1].push_back(h);
}
color_set[c2].clear();
if((c1 == color_index[X] && c2 == color_index[Y]) || (c1 == color_index[Y] && c2 = color_index[X]))
}
}
}
}
Compilation message
swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:41:32: error: 'color' was not declared in this scope
41 | for(int i = 0; i < n; i++) color[i] = i;
| ^~~~~
swap.cpp:67:113: error: lvalue required as left operand of assignment
67 | if((c1 == color_index[X] && c2 == color_index[Y]) || (c1 == color_index[Y] && c2 = color_index[X]))
| ^
swap.cpp:68:13: error: expected primary-expression before '}' token
68 | }
| ^
swap.cpp:73:1: warning: no return statement in function returning non-void [-Wreturn-type]
73 | }
| ^