跳到正文

wzsss2333

387352

、

在洛谷打开
资料、奖项与版本

资料

编号
387352
抓取

奖项

2024 CSP-S
二等奖
2024 NOIP
三等奖
2023 CSP-J
二等奖
2021 CSP-J
二等奖

1紫:2023/4/5

100橙:2023/8/23

开心地金明橙名:2023/8/28

300AC:2023/9/20

100黄:2024/2/23

1水黑:2024/2/26

400AC:2024/2/28

红!:2024/3/18

2k提交寄:2024/3/14

500AC:2024/3/21

100绿50蓝:2024/5/9

800AC&&100蓝:2024/10/15

缺省源:

C++
#include<bits/stdc++.h>
#define int long long
#define pb push_back
using namespace std;
const int M=2e6+10;
int n,m,x,y,t,k,a[M],b[M],c[M],f[M],u,v,w,ans,cnt,sum,tot;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	
}

尸山:

C++
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int> 
#define mp make_pair
#define pb push_back
using namespace std;
const int M=2e5+10,p=998244353,mod=998244353;
long long tot,cnt,dp[M],c[M],sum,ans,k,u,v,n,m,t,x,y,a[M],b[M],f[M];
bool vis[M];
char ch[M];
string s[M],s1;
int ls(int x){return x<<1;}
int rs(int x){return (x<<1)+1;}
struct node{
	int w,v;
};
vector<int>l[M];	
queue<int>q;
stack<int>st;
int gcd(int x,int y){
	if(x%y==0)
		return y;
	return gcd(y,x%y);
}
int qmi(int base,int b){
	int ans=1;
	while(b){
		if(b&1)ans=ans*base%mod;
		base=base*base%mod;b>>=1;
	}
	return ans;
}
void dfs(int u,int fa){
	for(int i=0;i<l[u].size();i++){
		int v=l[u][i];
		if(v!=fa)
			dfs(v,u);
	}
}
int init(){
	for(int i=1;i<=n;i++)
		f[i]=i;
}
int find(int x){
	if(f[x]!=x)
		f[x]=find(f[x]);
	return f[x];
}
bool cmp(node x,node y){
	if(x.v==y.v)
		return x.w>y.w;
	return x.v>y.v;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	init();
	for(int i=1;i<=n;i++){
		cin>>u>>v;
		l[u].pb(v);
		l[v].pb(u);
	}
	dfs(1,0);
	cout<<ans;
	return 0;
}

还没有收录这位用户的文章。