
并查集
kaisa158
HIT、机器学习
展开
-
poj 2513 Colored Sticks(欧拉回路 并查集 路径压缩 字典树)(困难)
这题不错,用到了三个知识点,我开始没用字典树,超时了。顺便学习了字典树。看到了一个不错的题解。可以用图论中欧拉路的知识来解这道题,首先可以把木棒两端看成节点,把木棒看成边,这样相同的颜色就是同一个节点问题便转化为:给定一个图,是否存在“一笔画”经过涂中每一点,以及经过每一边一次。这样就是求图中是否存在欧拉路Euler-Path。原创 2015-08-06 21:01:18 · 1164 阅读 · 1 评论 -
( 贪心/并查集)Codeforces Round #480 (Div. 2) C. Posterized
C. Posterizedtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputProfessor Ibrahim has prepared the final homework for his algorithm’s class. He asked ...原创 2018-05-28 17:40:25 · 272 阅读 · 0 评论 -
(DFS/并查集)Codeforces Round #479 (Div. 3) E. Cyclic Components
E. Cyclic Componentstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an undirected graph consisting of nn vertices and mm edges. Your...原创 2018-05-28 17:55:03 · 181 阅读 · 0 评论