Tên đăng nhập Điểm ▾ Bài tập Giới thiệu
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701
minhaidllc072019
Đoàn Minh Tâm
0 0

43 Đà Nẵng chào nm:)

32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701
chunn0810
Nguyễn Trung
0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0

include<bits/stdc++.h>

using namespace std;
vector<int> p,sl, mx;
void init(int n) {
p.resize(n+1);
sl.resize(n+1);
mx.resize(n+1);
for (int i=1; i<=n; i++){
p[i] = i;
sl[i]= 1;
mx[i]=i;
}

}

int find (int a) {
if (a == p[a]) return a;
return p[a]=find(p[a]);
}

void union_set (int a, int b) {
a = find(a);
b = find(b);
if (p[a]>p[b]) {
swap(a,b);
p[a]+= p[b];
p[b] = a;
}
}

int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n,m;
cin>> n>> m;
init(n);
int tg =n;
while (m--){
int a,b;
cin>> a>> b;
if (union_set(a, b)) {
sl = max(sl, p.size(a));
tg--;
}
cout<< tg << ' ' << sl << '\n';
}
return 0;
}

32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701
nguyenkhaclong
Nguyễn Khắc Long
0 0

tên mình là nguyễn khắc long mình đến từ tỉnh nghệ an mình là học sinh lớp 5A

32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0

Nguyễn Diệu Huyền

32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0

Lớp 10A2 trường THPT Đạ Huoai

32701 0 0
32701 0 0
32701 0 0

c

32701 0 0
32701 0 0
32701 0 0
32701 0 0
32701 0 0

ădsđá

32701 0 0