摘要: Intelligence System HDU - 3072 题意:一个人要传递命令给所有人,如果两人之间互达,不需任何费用,求最少费用 有向图强连通。 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int inf=0x3f3f3 阅读全文
posted @ 2017-08-18 16:58 yijiull 阅读(223) 评论(0) 推荐(0) 编辑
摘要: The Largest Clique UVA - 11324 题意:有向图最大团。求任意两点可达(不是互达)的最多点数。 先求出SCC,然后缩点,新图就变成了一个DAG,每个点的权值为内点的个数,用DP求解最大值。 1 #include <bits/stdc++.h> 2 using namespa 阅读全文
posted @ 2017-08-18 16:54 yijiull 阅读(359) 评论(0) 推荐(0) 编辑
摘要: Proving Equivalences HDU - 2767 UVALive - 4287 Equivalent Sets HDU - 3836 Equivalent Sets HDU - 3836 Equivalent Sets 题意:有向图,问还需要加几条边才变成强连通。 求出各强连通分量,缩 阅读全文
posted @ 2017-08-18 16:48 yijiull 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 迷宫城堡 HDU - 1269 题意:很明显是直接让判断有向图是不是强连通分量。 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxv=10010; 4 const int maxe=100010; 5 int n,m; 阅读全文
posted @ 2017-08-18 16:44 yijiull 阅读(177) 评论(0) 推荐(0) 编辑
摘要: SPF POJ - 1523 题意:无向图,求割顶以及去掉该割顶后有几个连通分量。 去掉一个割顶后,从割顶dfs遍历整张图,每扫一个连通分量计数器加1 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 using nam 阅读全文
posted @ 2017-08-18 16:34 yijiull 阅读(137) 评论(0) 推荐(0) 编辑
摘要: Railway HDU - 3394 题意:一个无向图,1求不在任何一个环里的边数;2求在不止一个环里的边数。 第一问明显就是求桥,第二问,如果求出的某个点双连通分量里面边数多于点数,说明不止一个环,那么所有的边都在不止一个环里。 该求点双连通的,,求成了边双连通。。。要仔细分析问题。 1 #inc 阅读全文
posted @ 2017-08-18 16:27 yijiull 阅读(332) 评论(0) 推荐(0) 编辑
摘要: Caocao's Bridges HDU - 4738 Caocao's Bridges 题意:一个带权无向图,破坏一条边的代价是权重,如果可以破坏一条边使得存在两点不能互达,输出最小代价。 【找权值最小的桥】 找到桥更新答案即可。 注意如果本身图就不连通,则不需要破坏,代价为0 如果图不存在桥,则 阅读全文
posted @ 2017-08-18 16:16 yijiull 阅读(246) 评论(0) 推荐(0) 编辑
摘要: Redundant Paths POJ - 3177 Redundant Paths 题意:一个无向图(有重边!!),问至少还要加多少边使得去掉任意一条边后任意两点仍可互达。 和上题poj3352基本相同,不过dfs的时候,不能用v!=f来判断是否能走,而要用当前走的边和上一条边是不是反向边 1 # 阅读全文
posted @ 2017-08-18 16:14 yijiull 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Road Construction POJ - 3352 题意:一个无向图(无重边),问至少还要加多少边使得去掉任意一条边后任意两点仍可互达。 无向图的边双连通分量(无重边) 先用一次dfs标记出割边,然后dfs标记出各联通分量 再根据割边,缩点重新建图,生成一颗树 则答案就是(叶子树+1)/2. 阅读全文
posted @ 2017-08-18 16:11 yijiull 阅读(279) 评论(0) 推荐(0) 编辑
摘要: Knights of the Round Table UVALive - 3523 题意:n个人开会,有些人相互憎恨不能挨着坐,且每场会议要保证是奇数个人。问有几个人一场会议也不能参加。 【无向图的点的双连通分量+二分图的判定】 不相互憎恨的人连边建图。 题目本质上要求的是不在任何一个奇圈上的人有几 阅读全文
posted @ 2017-08-18 16:08 yijiull 阅读(188) 评论(0) 推荐(0) 编辑
摘要: Chocolate HDU - 2282 题意:初始n块巧克力不均匀的放到n个盒子(环形)里,每次可以移动一块巧克力,问最少多少步使得每个盒子里有一块巧克力。 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxv=510 阅读全文
posted @ 2017-08-18 15:04 yijiull 阅读(183) 评论(0) 推荐(0) 编辑
摘要: Special Fish HDU - 3395 题意:n条鱼,被攻击后会产卵,如果i攻击j,那么后代会有g[i]^g[j]的值,求所有后代和的最大值。 KM 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int inf=0x3f3 阅读全文
posted @ 2017-08-18 14:59 yijiull 阅读(225) 评论(0) 推荐(0) 编辑
摘要: Interesting Housing Problem HDU - 2426 题意:n个人,m个房间,安排住宿。要求每个人不能分到不喜欢的房间,且使满意度最大。 不用slack几乎要超时~ 1 #include <bits/stdc++.h> 2 using namespace std; 3 con 阅读全文
posted @ 2017-08-18 14:51 yijiull 阅读(195) 评论(0) 推荐(0) 编辑
摘要: Going Home HDU - 1533 题意:给出地图,其中m和h个数相等,求所有m到h的总路程最短。 KM 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int inf=0x3f3f3f3f; 4 const int max 阅读全文
posted @ 2017-08-18 14:29 yijiull 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 奔小康赚大钱 HDU - 2255 题意:给出每个村民愿意为每个房子出的价钱,问怎么分配房子可以使收益最大。 KM算法 一直对slack数组有点迷~ 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int inf=0x3f3f3f3 阅读全文
posted @ 2017-08-18 14:12 yijiull 阅读(218) 评论(0) 推荐(0) 编辑
摘要: Clever Y POJ - 3243 题意:给a,c,b,求最小的x使得 ax≡b (mod c)。 扩展BSGS算法~ 1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 #include <cmath> 5 #def 阅读全文
posted @ 2017-08-18 13:25 yijiull 阅读(160) 评论(0) 推荐(0) 编辑
摘要: Searching the String ZOJ - 3228 题意:两种查询,普通的就是ac自动机模板,另外一种要求没有发生覆盖。 处理方式是判断一下如果当前匹配到的位置(u)减去上一次匹配到的位置(ed[u])大于该字符的深度(deep[u]),就加1。 1 #include <bits/std 阅读全文
posted @ 2017-08-18 10:55 yijiull 阅读(193) 评论(0) 推荐(0) 编辑
摘要: DNA repair HDU - 2457 题意:有些DNA序列是致病的,给你以个长DNA序列,问最少需要修改多少次使得其不含致病序列。 好多题解说的不清不楚的。。。最关键的地方往往没说清楚。。。 首先是进行了一步转换,将其理解为在建好的Trie图上走len(序列长度)步,走的路不能包含致病序列。 阅读全文
posted @ 2017-08-18 10:54 yijiull 阅读(299) 评论(0) 推荐(0) 编辑
摘要: 考研路茫茫——单词情结 HDU - 2243 题意: 和上一题基本差不多 比较坑的是,矩阵快速幂的时候m+1了,会爆int,所以要用long long 1 #include <bits/stdc++.h> 2 using namespace std; 3 #define ull unsigned l 阅读全文
posted @ 2017-08-18 10:52 yijiull 阅读(169) 评论(0) 推荐(0) 编辑
摘要: DNA Sequence POJ - 2778 题意: 昨天看了好久也没明白咋回事。。。今天忽然就理解了。。。 晚上再来补题解。。。 昨天看了好久也没明白咋回事。。。今天忽然就理解了。。。 晚上再来补题解。。。 1 #include <iostream> 2 #include <cstdio> 3 阅读全文
posted @ 2017-08-18 10:51 yijiull 阅读(155) 评论(0) 推荐(0) 编辑