# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
391405 | ali_tavakoli | Pipes (CEOI15_pipes) | C++14 | 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.
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define F first
#define S second
//#pragma GCC optimize("Ofast")
const int maxn = 1e5 + 5, maxlog = 19;
int n, m, pr[maxn], x, y;
int getpar(int v)
{
if(pr[v] == 0)
return pr[v] = v;
return (v == pr[v] ? v : pr[v] = getpar(pr[v]));
}
void un(int v, int u)
{
v = getpar(v);
u = getpar(u);
if(u != v)
par[u] = v;
}
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> m;
for(int i = 0; i < m; i++)
{
cin >> x >> y;
un(x, y);
}
cin.seekg(0);
for(int i = 0; i < m; i++)
{
cin >> x >> y;
}
}
/*
10 11
1 7
1 8
1 6
2 8
6 7
5 8
2 5
2 3
2 4
3 4
10 9
*/