Tên đăng nhập Điểm ▾ Bài tập Giới thiệu
1
phamducminh538 1565
Phạm Đức Minh
41163 702
2
khactrung1912 1788
Nguyễn Khắc Trung
37471 319
3
Sang522008 1525
Nguyễn Ngọc Cao Sang
37428 880

Nick Phụ: nguyenngoccaosang , NNCS

Newbie


#include <bits/stdc++.h>

using namespace std;

signed main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout<<"Cao Sangg";
}

Profile
FaceBook

4
vongocsinh 1948
Võ Ngọc Sinh
37177 343
5 35282 511
6
trvhung 1720
Trần Việt Hưng
33974 178
7
n2loclm 1233
Lê Minh Lộc
32778 689
8
elsu 989
NoNameNoBody
26053 213

Tôi elsu
Bị aaiibbxx phá hoại cuộc sống

9 24752 164
10
nguyenthinhuquynh 1227
Nguyễn Thị Như Quỳnh
24422 101

an tê ô

11 23695 70
12 23386 74
13
nguyenminhkhoi1234 1291
NguyenMinhKhoi
22913 176

Hello! I'm Nguyen Minh Khoi 🙂

14
MinhBùi_288
Bùi Minh
22389 119

15
HUNG_009 1070
Nguyễn Quang Nhật Hùng
20626 50

nhathung deptrai khoai to

16
tk22NguyenPhuongLam 1301
Nguyễn Phương Lâm
20490 329

Blockquote

Đây là:enter code hể

summary

summary
  • \[$detail$\]

17
nguyenngoccaosang 1442
Nguyễn Ngọc Cao Sang
20061 76

Acc phụ của Sang522008

18
thuongvng 1393
Trần Nguyễn Đan Quỳnh
19603 334
19 16324 21
20
quanpham_08092012
Phạm Minh Quân
16320 321

21
Ragnakrog 1069
Quá khó để quên em
16052 50
22
yenmai2832008
Vũ Thị Yến Mai
15493 125

hi 🙂

23 14649 29
24
lpa
Yae Miko
14448 48
25 13859 67
26 12648 16
27
Critcal
Nguyen Le Chau
12625 79

I, Diamond Sword, will strike you down! Okay just kidding but... Why are you even here? Well, you maybe my classmates but still, what is the point of coming here if you are not a hacker or some ragebaiter who decide to copyright strike the Nyan Cat?
Seriously, I can't be serious, like there can't be a single time where I just don't burst out laughing even at a moment where I don't want to. By the way, I am Critcal and I love Nyan Cat so that explain the words I just said, and to finish it off here is a gif of Nyan Cat and here is some EMOjis: 🙂 🙁 😈 😠 :

28 10187 14
29 9795 13
30 9702 29
31
memeq 1931
Võ Ngọc Sinh
8806 17
32 8205 45
33 8153 38
34 7812 23
35 7689 42
36 7561 40
37 7201 21
38
hnhlongvbh
Võ Hoàng Bảo Long
7141 24
39 6395 14
40
nguyenanhdaoht12 1223
nguyenvangiabao
5986 76

tôi tên là nguyễn văn giabao học sinh lớp 3/1.ha

41 5929 6
42 5860 70
43 4654 4

include<bits/stdc++.h>

using namespace std;

define endl "\n"

define pb push_back

define ll long long

const int maxn=1e6+1;

vector<int>adj[maxn],queries[maxn];
int n,q,par[maxn],rnk[maxn],ancestor[maxn];
bool visited[maxn];
map<pair\<int,int>,int>mp;
vector<pair\<int,int>>ans;

int find_set(int u){
while(par[u]!=u)u=par[u];
return u;
}

void union_set(int x,int y){
int xroot=find_set(x);
int yroot=find_set(y);
if(xroot==yroot)return;
if(rnk[xroot]<rnk[yroot])par[xroot]=yroot; else if(rnk[xroot]>rnk[yroot])par[yroot] = xroot;
else{
par[xroot]=yroot;
rnk[yroot]++;
}
}

void dfs(int w){
visited[w]=true;
ancestor[w]=w;
for(int u:adj[w]){
if(!visited[u]){
dfs(u);
union_set(w,u);
ancestor[find_set(u)] = w;
}
}
for(int u:queries[w]){
if(visited[u]){
mp[{min(w,u),max(u,w)}]=ancestor[find_set(u)];
}
}
}

int main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>q;
for(int i = 1; i < n; i++) {
int u, v;
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
for(int i = 1; i <= n; i++)
par[i] = i;
for (int i=1;i<=q;i++) {
int u, v;
cin >> u >> v;if (u>v)swap(u,v);ans.pb({u,v});
queries[u].push_back(v);
queries[v].push_back(u);
}
dfs(1);
for (auto u:ans)cout<<mp[u]<<endl;
}

44
minhtriethansome
Phạm Minh Triết
4627 71
45
Syn 1325
4521 8
46 4313 9
47 3500 7

sssss

48 2884 8
49 2637 2
50
anhuynt
Trịnh Nguyễn An Huy
2575 4
51 2378 5
52 2161 4
53 2050 6
53 1880 13
55 1849 15
56 1792 2
57 1501 1
57 1447 5
59 1423 9
60 1310 7
61 1132 4
62
hnhlongtm
Trần Minh Long
962 13
63 943 9
64 621 2
65 541 2
66 401 1
67 301 1
67 288 3
69 269 1
70 225 2
71 201 1
71 200 1
71 197 2
71 197 2
71 197 2
76 101 1
76 101 1
78 45 1
78 45 1
80 40 1
81 0 0
81 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;
}

81 0 0
81 0 0
81 0 0
81 0 0
81 0 0
81 0 0
81 0 0
81 0 0
81 0 0
81
BaAnhHT
Hoàng Bá Anh
0 0
81 0 0
81 0 0
81 0 0
81 0 0
81 0 0
81 0 0
81 0 0

nothing

81 0 0