会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
LMissher
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
8
9
10
11
12
13
14
下一页
2017年8月22日
hdu 1102
摘要: 题意:有n个村子与很多路,有些路已经修好了,求最小路程把所有村子连起来。 题解:用Kruskal算法,提前把已经修好的路合并。 代码: #include <cstdio>#include <algorithm>using namespace std;int n,q,Map[110][110],f[1
阅读全文
posted @ 2017-08-22 10:33 LMissher
阅读(120)
评论(0)
推荐(0)
2017年8月21日
hdu 2120
摘要: 题意:求连通块中有多少个环。 题解:如果两数的祖先相同则总数加1,否则合并。 代码: #include <cstdio>int pre[2100],sum[2100],tot;int find(int x){ int r = x; while(pre[r] != r){ r = pre[r]; }
阅读全文
posted @ 2017-08-21 14:57 LMissher
阅读(183)
评论(0)
推荐(0)
hdu 1856
摘要: 题意:求各个连通块中人数最大的那个并输出。 题解:在join函数里加一个num数组存各个联通块的人数,并找出最大的那个。(要压缩路径) 代码: #include <cstdio>using namespace std;int pre[210000],num[210000],max;int find(
阅读全文
posted @ 2017-08-21 14:42 LMissher
阅读(173)
评论(0)
推荐(0)
hdu 1166
摘要: 题目:线段树模板题。 代码: #include <cstdio>#include <algorithm>#include <string>#include <iostream>using namespace std;struct node{ int right,left; int sum;}tree
阅读全文
posted @ 2017-08-21 13:54 LMissher
阅读(150)
评论(0)
推荐(0)
hdu 2203
摘要: 题意:给两个字符串s1与s2,让s1循环移位看s2能否能成为s1的子串。 题解:让s1增长一倍,看s2是否是s1的子串。 代码: #include <cstdio>#include <cstring>int next[110000];char a[210000],b[110000];void Get
阅读全文
posted @ 2017-08-21 13:50 LMissher
阅读(182)
评论(0)
推荐(0)
hdu 1358
摘要: 题意:输入一个字符串,问长度大于2的所有从首元素开始的子串是否为循环串,是的话循环了几次。 题解:用Kmp算法求出每个i的next【i】,并设t=i-next【i】,if(i%t==0&&i/t>1)。则该子串为循环串并且循环次数为i/t。 代码: #include <string.h>#inclu
阅读全文
posted @ 2017-08-21 13:43 LMissher
阅读(133)
评论(0)
推荐(0)
hdu 1873
摘要: 题意:有n个人去三个医生处排队。每个人病情不一样,病情重的先看,如果病情相同则先来后到。 题解:用一个结构体的优先队列,病情优先,病情相同则序号优先。 代码: #include<iostream>#include<functional>#include<queue>#include <string>
阅读全文
posted @ 2017-08-21 13:29 LMissher
阅读(216)
评论(0)
推荐(0)
hdu 1213
摘要: 题意:小明开展一个聚会,邀请了n个朋友。认识的朋友才能在一桌(A认识B,B认识C,则C也认识A)。问需要几个桌子。 题解:用并查集求有几个联通块。 代码: #include <cstdio>int pre[1100];int find(int x){ int r = x; while(pre[r]
阅读全文
posted @ 2017-08-21 13:21 LMissher
阅读(147)
评论(0)
推荐(0)
poj 1258
摘要: 题目:给一个矩阵告诉每条边的权,求最小生成树。 题解:建树之后直接用kruskal。 代码: #include <algorithm>#include <iostream>using namespace std;struct node{//每条边的两顶点以及距离 int from; int to;
阅读全文
posted @ 2017-08-21 10:41 LMissher
阅读(187)
评论(0)
推荐(0)
poj 2377
摘要: 题目:给n个点,m条加权边。用最大距离连接所有点。 题解:裸的最大生成树。我用的kruskal。 代码: #include <iostream>#include <algorithm>using namespace std;struct node{//每条边的两顶点以及距离 int from; in
阅读全文
posted @ 2017-08-21 10:36 LMissher
阅读(144)
评论(0)
推荐(0)
上一页
1
···
8
9
10
11
12
13
14
下一页
公告