int find(int x) {
	if(f[x]==x)return x;
	return f[x]=find(f[x]);
}//查找
void merge(int x,int y)
{
	x=find(x);
	y=find(y);
	if(x!=y)f[x]=y;
}//合并  通常放在int main()里

 

相关文章:

  • 2022-01-06
  • 2021-11-13
  • 2021-06-04
  • 2021-11-09
猜你喜欢
  • 2022-12-23
  • 2021-11-01
  • 2021-10-10
  • 2022-02-12
  • 2022-01-02
相关资源
相似解决方案