HDU
KLFTESPACE
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Monkey and Banana HDU - 1069
//贪心 #include<cstdio> #include<algorithm> using namespace std; struct Brick { int x,y,z;//长宽高 }brick[200]; int ant; void UpDate(int x,int y,int z) { brick[ant].x = x; brick[ant]...原创 2019-09-06 15:32:43 · 195 阅读 · 0 评论 -
Ice_cream’s world II HDU - 2121
本来想套下UVA - 11183 Teen Girl Squad ....但是WA了 去重边去掉就可以了,...然鹅我没明白为啥。。。 无根最小树形图 个人理解 加个虚点和这个虚点指向所有点的虚边,则根最后确定为以虚点为根的边指向的那个点,,,每次都会变,当找到最小树形图以后...该根点就确定了 #include <cstdio> #include <...原创 2019-08-08 13:14:33 · 265 阅读 · 0 评论 -
Transfer water HDU - 4009
//将自己凿井那部分构造成以0为起点,凿井地为终点,所花费为边权值,然后,找以0为根(因为肯定会有自凿井)最小树形图 //如果没有一个自打井的费用比连管低的话,无根最小树形图 // #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #in...原创 2019-08-08 18:05:34 · 335 阅读 · 0 评论 -
Qin Shi Huang's National Road System HDU - 4081(RE)
套的之前的The Unique MST POJ - 1679,,,然后,发现我在更新G的时候,语句不对,应该使用根结点来更新的而不是当前节点,改了以后MAX就更新对了....最后RE了.... 先放着,等以后再找找问题..... #include<iostream> #include<cstdio> #include<queue> #include<v...原创 2019-08-06 20:11:43 · 183 阅读 · 0 评论 -
Simpsons’ Hidden Talents HDU - 2594
有一种是直接将两个合并,getnext得到前后缀最长匹配字段即可,但是要注意长度小于两个字符串长度 另一种办法是得到一个字符模板串的next数组,然后 对另一字符串进行匹配,直至字符串末尾,若正在匹配中的模板串下标值不为0,说明可匹配,输出即可 #include<iostream> #include<cstdio> #include<cstring> ...原创 2019-08-14 15:53:23 · 279 阅读 · 0 评论 -
Number Sequence HDU - 1711
KMP模板 TLE了 输入输出换成标准输入输出AC了... #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> using namespace std; const int N = 1e6+5; in...原创 2019-08-11 22:51:58 · 231 阅读 · 0 评论 -
剪花布条 HDU - 2087
刚开始TLE了,是因为找到符合的字符串位置后,j = i+1了...是我蠢了..应该是j = 0;即 模式串向后一模式串个 长度位.... 后来 WA...怎么看都没问题...然后发现cnt每次都没初始为0..... #include<iostream> #include<cstdio> #include<cstring> #include<cma...原创 2019-08-12 23:15:40 · 156 阅读 · 0 评论 -
Oulipo HDU - 1686
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> using namespace std; const int N = 1e6+5; int nxt[N]; int cnt = 0; char s1[N],...原创 2019-08-12 23:17:16 · 154 阅读 · 0 评论 -
Cyclic Nacklace HDU - 3746
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> using namespace std; const int N = 1e6+5; int nxt[N]; int cnt = 0; char s1[N],...原创 2019-08-12 23:18:26 · 226 阅读 · 0 评论 -
Keywords Search HDU - 2222
//AC自动机模板 这道题直接用字符的ASCLL码表示会TLE。。。。所以用0-26表示 #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include <queue> using namespace std; co...原创 2019-08-16 17:43:07 · 152 阅读 · 0 评论 -
Period HDU - 1358
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> using namespace std; const int N = 1e6+5; int nxt[N]; int cnt = 0; char s1[N],...原创 2019-08-13 10:00:23 · 134 阅读 · 0 评论 -
还是畅通工程 HDU - 1233
#include<iostream> #include<cstdio> #include<queue> #include<cstring> using namespace std; const int N = 1000+5; struct Edge{ int u, v, dist; Edge...原创 2019-08-05 18:02:05 · 156 阅读 · 0 评论 -
Piggy-Bank HDU - 1114
//完全背包 #include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> using namespace std; const int N = 500+5; const int M = 10000+5; c...原创 2019-09-06 17:39:14 · 165 阅读 · 0 评论 -
最少拦截系统 HDU - 1257
//定义及解释详见最长递增子序列 C++ STL lower_bound,upper_bound的使用总结 #include<bits/stdc++.h> using namespace std; #define MAXN 40005 int arr[MAXN], ans[MAXN], len; int main() { int n,i; while...原创 2019-09-06 19:22:47 · 158 阅读 · 0 评论 -
FatMouse's Speed HDU - 1160
#include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> #include<map> #include<set> #include<vector> #define ll long long using namespa...原创 2019-09-07 09:36:12 · 168 阅读 · 0 评论 -
Clairewd’s message HDU - 4300
扩展KMP的详细理解 将s2当做密文进行解密为sts2(明+?),完成后将s2(密+明)和sts2进行匹配 。 因为密文解密后即为明文,但是 所给的s2明文不全,所以只可能部分匹配,或不匹配,所以,只需找到匹配的点以及匹配的长度是否大于等于s2.length(),若是,则0-i为密文,明文则在对应的sts2里找。 #include<iostream> #include<...原创 2019-09-13 23:04:35 · 230 阅读 · 0 评论 -
Best Reward HDU - 3613
马拉车算法 也可以做两次EKMP求解 #include <bits/stdc++.h> using namespace std ; typedef long long ll ; const int N = 5e5 + 10 ; const int INF = 0x3f3f3f3f ; string s, t; int len, L[N], R[N] ; int va...原创 2019-09-14 18:31:23 · 259 阅读 · 0 评论 -
吉哥系列故事——完美队形II HDU - 4513
//主要中间的-1以及起点为无穷大,,因为起始递增的话需要不符合递增条件 #include <iostream> #include <algorithm> #include <cstring> #include <cstdio> using namespace std; const int MAXN=1e6+10; int h[MAXN];...原创 2019-09-14 21:27:47 · 214 阅读 · 1 评论 -
Girls' research HDU - 3294
//计算左右端点,转换字符串 然后用cin的时候会TLE。。。 用了 ios::sync_with_stdio(false);也不行,... #include <iostream> #include <algorithm> #include <cstring> #include <cstdio> using namespace std...原创 2019-09-14 22:03:18 · 205 阅读 · 0 评论 -
Theme Section HDU - 4763
//用next[len] 可找到EAEBE的前后缀即E,然后再中间找符合EAEBE的前后缀(前后缀可根据中间查找情况进行缩略即继续查找E的前后缀),需要和已定前后缀间隔一倍E的距离,以防出现EEBE或EAEE的情况 #include<iostream> #include<cstdio> #include<cstdlib> #include<cstri...原创 2019-09-14 23:02:35 · 201 阅读 · 0 评论 -
病毒侵袭持续中 HDU - 3065
刚开始树里的数组开小了...TLE 询问字符串长度不够 RE了 未考虑多组输入,WA,, AC #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include <queue> using namespace ...原创 2019-09-17 21:55:46 · 161 阅读 · 0 评论 -
Lowest Bit
#include<iostream> #include <cstdio> #include <algorithm> using namespace std; int lowbit(int x){ return x&-x; } int main() { int x; while(cin >> x &&a...原创 2019-02-20 11:35:24 · 185 阅读 · 0 评论 -
畅通工程
某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( < 1000 )和道路数目M;随后的M行对应M条道路,每行给出一对正整...原创 2018-05-05 16:10:37 · 392 阅读 · 0 评论 -
A - {A} + {B}
给你两个集合,要求{A} + {B}. 注:同一个集合中不会有两个相同的元素.Input每组输入数据分为三行,第一行有两个数字n,m(0<n,m<=10000),分别表示集合A和集合B的元素个数.后两行分别表示集合A和集合B.每个元素为不超出int范围的整数,每个元素之间有一个空格隔开.Output针对每组数据输出一行数据,表示合并后的集合,要求从小到大输出,每个元素之间有一个空格隔开...原创 2018-05-27 22:13:01 · 273 阅读 · 0 评论 -
sort HDU - 1425(本来想用vector做下,练习下,结果TLE,然后C++自带sort可以过)
给你n个整数,请按从大到小的顺序输出其中前m大的数。 Input每组测试数据有两行,第一行有两个数n,m(0<n,m<1000000),第二行包含n个各不相同,且都处于区间[-500000,500000]的整数。 Output对每组测试数据按从大到小的顺序输出前m大的数。 Sample Input 5 3 3 -35 92 213 -644 Sample Output ...原创 2018-05-28 23:01:46 · 485 阅读 · 0 评论 -
Perfection
From the article Number Theory in the 1994 Microsoft Encarta: ``If a, b, c are integers such that a = bc, a is called a multiple of b or of c, and b or c is called a divisor or factor of a. If c is no...原创 2018-05-31 11:55:31 · 535 阅读 · 0 评论 -
士兵队列训练问题 HDU 1276
某部队进行新兵队列训练,将新兵从一开始按顺序依次编号,并排成一行横队,训练的规则如下:从头开始一至二报数,凡报到二的出列,剩下的向小序号方向靠拢,再从头开始进行一至三报数,凡报到三的出列,剩下的向小序号方向靠拢,继续从头开始进行一至二报数。。。,以后从头开始轮流进行一至二报数、一至三报数直到剩下的人数不超过三人为止。 Input 本题有多个测试数据组,第一行为组数N,接着为N行新兵人数,新兵...原创 2018-08-16 20:22:06 · 240 阅读 · 0 评论 -
Bone Collector HDU - 2602
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> using namespace std; struct Pack{ int cost; int vol; }; int dp[1000+5][1000+5]; Pack a[1000...原创 2018-12-02 21:47:59 · 202 阅读 · 0 评论 -
A计划 HDU2102
在开始的时候需要将map初始化,要不然会WA,还有就是#不会向四周扩展。 我这种是三维搜索。 应该还有一种方法是将两层合并为一层,就是#对应的那层是'.'就改为'.',否则不变。在合并的一层中‘#’不会向四周扩展。P直接改到对应的位置。然后二维搜索就可以了。 #include<iostream> #include<cstdlib> #include<qu...原创 2019-02-23 22:36:15 · 206 阅读 · 0 评论 -
How Many Answers Are Wrong
//在查询的时候 ,想dist在前面,递归在后面,WA,发现dist应该是从根部到叶子相加赋值,而不是叶子+父节点倒着到根。 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N = 200000+5; int pre[N], d...原创 2019-02-18 21:46:59 · 175 阅读 · 0 评论 -
A + B HDU1228
#include<iostream> #include<cstdio> #include <string.h> #include<algorithm> #include <map> using namespace std; string num[10] = {"zero","one","two",&quo原创 2019-02-19 14:24:29 · 269 阅读 · 0 评论 -
Fibonacci Numbers HDU3117
用了提取大数前四位和矩阵快速幂。 /*矩阵快速幂*/ #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; //const int mod = 10000; typ...原创 2019-02-25 11:14:16 · 245 阅读 · 0 评论 -
产生冠军 HDU 2094
有一群人,打乒乓球比赛,两两捉对撕杀,每两个人之间最多打一场比赛。 球赛的规则如下: 如果A打败了B,B又打败了C,而A与C之间没有进行过比赛,那么就认定,A一定能打败C。 如果A打败了B,B又打败了C,而且,C又打败了A,那么A、B、C三者都不可能成为冠军。 根据这个规则,无需循环较量,或许就能确定冠军。你的任务就是面对一群比赛选手,在经过了若干场撕杀之后,确定是否已经实际上产生了冠军。 Inp...原创 2018-05-11 21:06:06 · 345 阅读 · 0 评论 -
Verdis Quo HDU2352
在(代码一)字符串转枚举类型是,char应设为char c[], 而不是char * c;不然会RE(可能是数组越界)。然后 感觉测试样例有个BUG,就是IIV应该是3,然而代码二(好早以前写的)直接if完,IIV是5,但是AC了。这次主要是想练习练习枚举。然后 刚开始还有个想法就是用stringstream 直接将char转化为NUM(枚举),然而,编译不过去,需要自己编写>>重载...原创 2019-02-20 16:48:30 · 267 阅读 · 0 评论 -
确定比赛名次 HDU - 1285 (拓扑排序)
#include<iostream> #include<cstdio> #include<vector> using namespace std; const int N = 500+5; int main() { int n, m; while(cin >> n >> m && n ...原创 2019-03-05 16:51:27 · 332 阅读 · 0 评论 -
胜利大逃亡 HDU - 1253
这个题应该是很简单的一道题,,,但是我先做的 Dungeon Master POJ - 2251 然后.....两道题又特别像.....然后 就掉进坑里,,..........爬出来了....发现是bfs在入队列判断那儿有问题,,将范围控制在0-L,R,C即可,而不是题目定义的最大整数50.... 但是这个是针对第二版WA的代码,,,第一版的直接是'0'和‘1’的还在坑里面.......原创 2019-03-06 20:45:35 · 276 阅读 · 0 评论 -
敌兵布阵 HDU-1166
参见https://blog.youkuaiyun.com/flushhip/article/details/79165701 https://blog.youkuaiyun.com/forever_kirito/article/details/78694203 //树状数组 #include<iostream> #include<cstdio> #include<algor...原创 2019-03-19 21:42:02 · 313 阅读 · 0 评论 -
Reward HDU - 2647(两种解法:dfs, 拓扑)
//在做的时候,邻接表构造错了,导致出现死循环问题tle。。。还有就是topo里面sum写在了if外,,,,导致计数错误WA //dfs已解出 #include<iostream> #include<cstdio> #include <string.h> #include<algorithm> #include<queue> u...原创 2019-03-15 22:47:40 · 229 阅读 · 0 评论 -
Digital Square HDU4394
//刚开始int WA了 改为LL就AC了 在队列里忘了加q.pop()导致死循环没输出,,然后 在进位那儿的i写成了tmp.pos*10。。。。导致结果一直为同一个数..;.... #include<iostream> #include<cstdio> #include<queue> using namespace std; typede...原创 2019-03-18 10:26:29 · 214 阅读 · 0 评论 -
I Hate It HDU - 1754 (树状数组求区间最大值)
//注意题意:文件结束...... //数组清零应放在循环里 思路见树状数组求区间最大值 #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> using namespace std; const int N = 300000+5; in...原创 2019-04-13 16:59:18 · 288 阅读 · 0 评论
分享