Username Points Problems ▾ About
1
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

2
phamducminh538 1565
Phạm Đức Minh
41235 703
3
n2loclm 1233
Lê Minh Lộc
32778 689
4 35282 511
5
vongocsinh 1948
Võ Ngọc Sinh
37177 343
6
thuongvng 1393
Trần Nguyễn Đan Quỳnh
19603 334
7
tk22NguyenPhuongLam 1301
Nguyễn Phương Lâm
20490 329

Blockquote

Đây là:enter code hể

summary

summary
  • \[$detail$\]

8
quanpham_08092012
Phạm Minh Quân
16320 321

9
khactrung1912 1788
Nguyễn Khắc Trung
37471 319
10
elsu 989
NoNameNoBody
26053 213

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

11
trvhung 1720
Trần Việt Hưng
33974 178
12
nguyenminhkhoi1234 1291
NguyenMinhKhoi
22913 176

Hello! I'm Nguyen Minh Khoi 🙂

13 24752 164
14
yenmai2832008
Vũ Thị Yến Mai
15493 125

hi 🙂

15
MinhBùi_288
Bùi Minh
22389 119

16
nguyenthinhuquynh 1227
Nguyễn Thị Như Quỳnh
24422 101

an tê ô

17
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: 🙂 🙁 😈 😠 :

18
nguyenanhdaoht12 1223
nguyenvangiabao
5986 76

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

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

Acc phụ của Sang522008

20 23386 74
21
minhtriethansome
Phạm Minh Triết
4627 71
22 23695 70
23 5860 70
24 13859 67
25
Ragnakrog 1069
Quá khó để quên em
16052 50
26
HUNG_009 1070
Nguyễn Quang Nhật Hùng
20626 50

nhathung deptrai khoai to

27
lpa
Yae Miko
14448 48
28 8205 45
29 7689 42
30 7561 40
31 8153 38
32 14649 29
33 9702 29
34
hnhlongvbh
Võ Hoàng Bảo Long
7141 24
35 7812 23
36 16324 21
37 7201 21
38
memeq 1931
Võ Ngọc Sinh
8806 17
39 12648 16
40 1849 15
41 6395 14
42 10187 14
43
hnhlongtm
Trần Minh Long
962 13
44 9795 13
45 1880 13
46 4313 9
47 943 9
48 1423 9
49
Syn 1325
4521 8
50 2884 8
51 1310 7
52 3500 7

sssss

53 2050 6
54 5929 6
55 2378 5
56 1447 5
57
anhuynt
Trịnh Nguyễn An Huy
2575 4
58 1132 4
59 2161 4
60 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;
}

61 288 3
62 621 2
63 541 2
64 1792 2
65 225 2
66 197 2
67 2637 2
68 197 2
68 197 2
70 101 1
71 1501 1
72 200 1
73 269 1
74 101 1
75 401 1
76 45 1
76 45 1
78 40 1
79 201 1
80 301 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