Week 10

1.

P1636

Einstein学画画

代码:

找规律。。。。

2.

P8654

[蓝桥杯 2017 国 C] 合根植物

并查集

代码:

#include<bits/stdc++.h>usingnamespacestd;
int fa[1010*1010],n,m,T,book[1010*1010],cnt[1010*1010],ans=0;
intfind(int x){
	return (x==fa[x]?x:find(fa[x]));
}
intmain(){
	cin>>n>>m;
	cin>>T;
	for(int i=1;i<=n*m;i++)fa[i]=i;
	while(T--){
		int a,b;
		cin>>a>>b;
		book[a]=1;
		book[b]=1;
		int fx=find(a);
		int fy=find(b);
		if(fx!=fy){
			fa[fx]=fy;
		}
		fa[a]=find(fx);
		fa[b]=fy;
	}
	for(int i=1;i<=n*m;i++){
		if(1){
			if(cnt[find(i)]==0){
				ans++;
				cnt[find(i)]++;
			}
		}
	}
	cout<<ans;
	return0;
}

3.

P3958

[NOIP2017 提高组] 奶酪

依然是并查集

4.

P1119

灾后重建

Floyed板子题

5.

P2504

[HAOI2006]聪明的猴子

最小生成树,就是证明有点麻烦

代码:

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值