# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
394893 | irmuun | Swapping Cities (APIO20_swap) | C++17 | 0 ms | 0 KiB |
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 a,b,i,n,m,link[100000],edge[100000],sz[100000],x,y,ans[100000];
pair<int, pair<int,int> >p[200000];
int find(int x){
if(link[x]==x){
return x
}
return link[x]=find(x);
}
bool same(int a,int b){
if(find(a)==find(b)){
return true;
}
else{
return false;
}
}
void unite(int a,int b){
a=find(a);
b=find(b);
if(sz[a]<sz[b]){
swap(a,b);
}
link[b]=a;
sz[a]+=sz[b];
}
void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
m=M;