并查集
xiao_you_you
这个作者很懒,什么都没留下…
展开
-
Mahmoud and a Dictionary CodeForces - 766D
Mahmoud wants to write a new dictionary that contains n words and relations between them. There are two types of relations: synonymy (i. e. the two words mean the same) and antonymy (i. e. the two wor...原创 2018-07-28 08:53:22 · 220 阅读 · 0 评论 -
并查集模版
#include<iostream>#include<cstdio>using namespace std;const int maxn=1e6+7;int pre[maxn];int Find(int x) //查找x元素所在的集合,回溯时压缩路径{ if (x != pre[x]) { pre[x] = Find...原创 2018-12-07 11:58:20 · 88 阅读 · 0 评论 -
合根植物
问题描述 w星球的一个种植园,被分成 m * n 个小格子(东西方向m行,南北方向n列)。每个格子里种了一株合根植物。 这种植物有个特点,它的根可能会沿着南北或东西方向伸展,从而与另一个格子的植物合成为一体。 如果我们告诉你哪些小格子间出现了连根现象,你能说出这个园中一共有多少株合根植物吗?输入格式 第一行,两个整数m,n,用空格分开,表示格子的行数、列数(1<m,n...原创 2019-03-25 21:07:43 · 69 阅读 · 0 评论