摘要: Portal:http://acm.hdu.edu.cn/showproblem.php?pid=1863 依然最小生成树+并查集 因为不保证所有村庄在一个强连通分量里,所以用并查集要判断能否“畅通” 1 #include<iostream> 2 #include<algorithm> 3 #inc 阅读全文
posted @ 2016-07-05 22:39 MukoiAoi 阅读(190) 评论(0) 推荐(0) 编辑
摘要: Portal: http://acm.hdu.edu.cn/showproblem.php?pid=1233 最小生成树模板题 kruskal+并查集 因为给出了所有村庄间的距离,所以保证所有村庄在一个强连通分量里,所以直接kruskal 1 #include<iostream> 2 #includ 阅读全文
posted @ 2016-07-05 22:30 MukoiAoi 阅读(134) 评论(0) 推荐(0) 编辑
摘要: int setfind(int xx) { int fa=father[xx]; if(fa==xx) return fa; else return father[xx]=setfind(fa); } void setunion(int xx,int yy) { int X=setfind(xx); int Y=setfind(yy); if(X=... 阅读全文
posted @ 2016-07-02 15:55 MukoiAoi 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 。。。 30次提交2次AC 这道题告诉我一个道理:交题要在评测机高兴的时候交(大雾) 其实是好好看题啦 话说输入0输出1 2333333333333333333333333333 邪道:直接map+并查集 路径压缩时把val[]所表示的高度改为子孙数即可 映射是好用 但1e6*10组数据*并查集的O 阅读全文
posted @ 2016-07-02 15:55 MukoiAoi 阅读(224) 评论(0) 推荐(0) 编辑
摘要: Portal: http://acm.hdu.edu.cn/showproblem.php?pid=1325 1272的原版? 依然并查集+map,ID分配正是好用 话说为什么hdu上rank和_是保留字? 与1272相比,由无向树变成了有向树,所以在1272的基础上维护结构时去掉左右合并rank优 阅读全文
posted @ 2016-07-02 13:48 MukoiAoi 阅读(110) 评论(0) 推荐(0) 编辑
摘要: Portal: http://acm.hdu.edu.cn/showproblem.php?pid=1272 是道好题 噗噗噗,咱果断的优化大展神威,一次AC,爽到~ 底下Discuss哀鸿遍野,出题者卡的一手好常数. 限制是1000MS直接300MS过了,然而最快的人直接0MS,%%% 1 #in 阅读全文
posted @ 2016-07-01 23:19 MukoiAoi 阅读(112) 评论(0) 推荐(0) 编辑
摘要: Portal:http://codevs.cn/problem/2639/ 简单题,并查集再加个map,一开始我以为要用图论,失算 FML,我的代码怎么这么长。。。优化太多反而慢啊。。。大常数大师啊。。。 1 #include<iostream> 2 #include<algorithm> 3 #i 阅读全文
posted @ 2016-07-01 22:29 MukoiAoi 阅读(134) 评论(0) 推荐(0) 编辑
摘要: Portal:http://poj.org/problem?id=1163 DP经典题,IOI94考题,在各大OJ上都有 1 #include<iostream> 2 #include<algorithm> 3 #include<set> 4 #include<cstdio> 5 #include< 阅读全文
posted @ 2016-06-30 19:27 MukoiAoi 阅读(290) 评论(0) 推荐(0) 编辑
摘要: Portal:http://acm.hdu.edu.cn/showproblem.php?pid=1232 模板题2 DA☆ZE 话说这题跟隔壁的HDU1213有区别吗。。。 话说HDU有中文题orz 话说输入到0为止到底是for(cin>>_;_!=0;cin>>_)还是while(cin>>_) 阅读全文
posted @ 2016-06-28 21:53 MukoiAoi 阅读(109) 评论(0) 推荐(0) 编辑
摘要: Portal:http://acm.hdu.edu.cn/showproblem.php?pid=1213 模板题~开心 第一次写并查集 WA一次,PE一次才AC TAT 1 #include<iostream> 2 #include<algorithm> 3 #include<set> 4 #in 阅读全文
posted @ 2016-06-28 21:35 MukoiAoi 阅读(130) 评论(0) 推荐(0) 编辑