Tên đăng nhập Điểm ▾ Bài tập Giới thiệu
1
phamducminh538 1709
Pham Duc Minh
37586 612


me

me

2
vongocsinh 1647
Võ Ngọc Sinh, Quảng Bình
36733 338
3
khactrung1912 1670
Nguyễn Khắc Trung
36159 234
4
Sang522008 1525
Nguyễn Ngọc Cao Sang
34210 794

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

5
n2loclm 1233
Lê Minh Lộc
32753 665
6
huyquang_25 1630
Lê Quang Huy
32434 483
7
trvhung 1727
Trần Việt Hưng
29663 155
8 26139 329

TRÔN VN =)

9 25606 164
10
elsu 989
NoNameNoBody
25301 209

I am elsu
Bị aaiibbxx phá hoại cuộc sống

11 21537 62
12
nguyenngoccaosang 1442
Nguyễn Ngọc Cao Sang
20061 76

Acc phụ của Sang522008

13 16910 77
14
tk22NguyenPhuongLam 1301
Nguyễn Phương Lâm
16383 261
15
Ragnakrog 1069
Quá khó để quên em
16052 50
16 13859 67
17
yenmai2832008
Vũ Thị Yến Mai
12864 120

hi 🙂

18 11568 21
19 11554 15
20 10187 14
21 9795 13
22 9702 29
23
memeq 1931
8806 17
24 8535 43
25 7561 40
26
nguyenminhkhoi1234
NguyenMinhKhoi
6322 56
27 6195 19
28 5929 6
29 5860 70
30 5856 37
31
nguyenanhdaoht12 1223
nguyenvangiabao
5854 74

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

32 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;
}

33
Syn 1325
4521 8
34
Critcal
Nguyen Le Chau
3455 29

This account was made to exercise coding skill ,which my program languages teacher tell me and his other pupils to do. Now it's time to moving to other things.
I know this doesn't talk about my information but that is PRIVATE INFO that i can't tell to YOU, the one who is reading this. I was pretty nervous when i see the problems tab of me are different, but it's just a setting. it took me some time to found it's a setting, pretty fun case, right? Alright, thanks for reading this! BTW, I love Nyan cat!

35 3197 5

sssss

36 2957 6
37 2161 4
38 2050 6
38 1880 13
40 1876 7
41 1849 15
42 1685 6
43
anhuynt
Trịnh Nguyễn An Huy
1541 3
44 1501 1
44 1447 5
46 1423 9
47 1310 7
48 1268 9
49 1203 3
50 1132 4
51 943 9
52 923 4
53
hnhlongtm
Trần Minh Long
906 12
54
hnhlongvbh
Võ Hoàng Bảo Long
872 11
55 621 2
56 541 2
57 401 1
58 288 3
59 269 1
60 225 2
61 201 1
61 200 1
61 197 2
61 197 2
61 197 2
66 101 1
66 101 1
68 45 1
68 45 1
70 40 1
71
thuongvng
Nguyễn Thị Thương
0 0
71 0 0
71 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;
}

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

nothing

71 0 0
71 0 0
71 0 0
71 0 0
71 0 0
71 0 0

bhhh

71 0 0
71 0 0