随笔分类 - 并查集
摘要:连着三天做并查集了,一天一道,效率低呀···并查集之后是最小生成树再之后是最短路径,回学校之前把图论基本算法过一遍吧。回学校还要复习DSA因为开学就是乙级PAT了。当然英语和健身也不能落下。这道题要考虑的地方有①空树②无环③非森林④1 1 0 0 不是树 不能自己指向自己#include#inclu...
阅读全文
摘要:和昨天晚上做的 A Bug‘s Life是一样思路的题···开始做的时候还是有些小问题,就在各种问题中进步吧。#include#define Size 100000int N, M;int Rel[Size+1], Pre[Size+1];void Init(){ for( int i...
阅读全文
摘要:思路参考这里(较详细)一开始总是WA调了一晚上原来···Init初始化写在scanf上面了···哎╮(╯▽╰)╭anyway!对并查集的理解更深了一步!#include#includeusing namespace std;#define Size 2000struct node{ i...
阅读全文
摘要:#include#includeusing namespace std;#define Size 10000000int Par[Size+1], Sum[Size+1];int GetPar( int a ){ if( Par[a]!=a ) Par[a] = ...
阅读全文
摘要:#includeusing namespace std;#define Size 30000int Pre[Size+1], Sum[Size+1];// Sum[i] 表示 第i组 的人数int Get_Pre( int a ){ if( Pre[a]!=a ) ...
阅读全文
摘要:超有爱讲解 点这里#includeusing namespace std;#define Size 1000int Father[Size];int Find( int n ){ while( n != Father[n] ) n = Father[n]; ...
阅读全文

浙公网安备 33010602011771号