![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
hdu
Red_Flame
热爱C/C算法Windwos编程.
展开
-
hdu 4339 线段树
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4339You are given two strings s1[0..l1], s2[0..l2] and Q - number of queries.Your task is to answer next queries:1) 1 a i c - you should set i-th c原创 2012-11-28 02:23:42 · 481 阅读 · 0 评论 -
hdu2553
N皇后的问题,解法好多种,这里采用的是递归回溯,但内存限制吧,用了打表的方法,其实用bfs可以不用打表.主要是两个函数,递归函数和判断是否合法.AC code:#include #include using namespace std;#define N 10int Maze[N][N];int sum;int n;bool Valid(int i,int j);vo原创 2013-03-14 18:55:33 · 1454 阅读 · 0 评论 -
hdu2523
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2523Hash的水题,数据量及组合数范围都可以估算.AC code:#include #include using namespace std;int main(){ int i,j,test,k,n,hash[2002],a[1002],result[2002]; cin>>tes原创 2013-03-16 15:33:43 · 784 阅读 · 0 评论 -
hdu 1272
链接:http://acm.hdu.edu.cn/showproblem.php?pid=12722个条件:1,用并查集判断是否有环.2, 在一根树中.AC code:#include using namespace std;#define NUM 100002int father[NUM],num[NUM];void Init(){ for(int i=0;i原创 2013-03-20 01:04:11 · 578 阅读 · 0 评论 -
hdu1829 A Bug's Life
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1829题意:判断一些类似男女配对数据里是否存在同性恋,用并查集判断是否存在同性恋,即同一集合里面是同性的人,增加辅助数组判断性别.Ac code:#include#includeusing namespace std;#define NUM 10005int father[NUM],se原创 2013-04-04 23:39:43 · 660 阅读 · 0 评论 -
hdu4287
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4287解题思路:先把单词化成数字插入到字典树,然后查询次数.AC code:#include #includeusing namespace std;#define N 5005char num[N][7]; //数字char str[7]; //字母struct node原创 2013-04-10 22:05:44 · 600 阅读 · 0 评论 -
hdu 1251 字符串前缀 子典树
今天找了一道关于Tire的问题,题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1251处理关于前缀出现次数的问题,定义结点存放分支的个数,依次往下循找,如果合理,则返回分支个数否则返回零。 /****************************华丽的分割线~~**********************************/原创 2012-10-22 22:08:36 · 739 阅读 · 0 评论 -
hdu1381
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1381题意中的NC不懂有什么用...用的STL里面的map过的.AC code:#include #include #include #include using namespace std;int test,N,NC;string str;map m;int原创 2013-03-15 12:07:40 · 1132 阅读 · 0 评论 -
hdu 4318 SPFA 最短路
AC code:#include#include#include#include#include#includeusing namespace std;#define N 50005struct Edgenode{ int v,next; double cost;}Edge[N*55];int edgenumber,head[N];int原创 2013-05-12 03:06:51 · 800 阅读 · 0 评论 -
hdu2716
#include #include #include "stdio.h"using namespace std;int main(){ char str1[26],str2[81]; while (scanf("%s",str1)!=EOF) { getchar(); gets(str2); int i,len=strlen(str2); for(i=0;i<len原创 2013-03-01 19:02:18 · 505 阅读 · 0 评论 -
hdu 2545
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2545并查集解决.AC code:#include #include using namespace std;#define Max 100001int father[Max];void Init(){ int i; for(i=0;i<Max;++i) father[i]原创 2013-02-07 17:24:53 · 636 阅读 · 0 评论 -
hdu 1811
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1811ps:输入格式看错了,提交了好几次。。原来中间还有空格。。自从Lele开发了Rating系统,他的Tetris事业更是如虎添翼,不久他遍把这个游戏推向了全球。为了更好的符合那些爱好者的喜好,Lele又想了一个新点子:他将制作一个全球Tetris高手排行榜,定时更新,名堂要比福布原创 2013-02-05 22:24:03 · 653 阅读 · 0 评论 -
线段树 hdu 1166
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1166线段树第一题~ ////////////////////分割线///////////////////////////////线段树:一种二叉搜索树,类似于区间树,各个字节点为线段或者单元区间,能基本保证每个操作的复杂度为O(logn).对于一个非叶节点区间[a,b],其左儿原创 2012-11-25 03:04:51 · 557 阅读 · 0 评论 -
hdu 1004 hash map
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004水题,拿来练练手.InputInput contains multiple test cases. Each test case starts with a number N (0 < N <= 1000) -- the total number of balloons distrib原创 2012-11-29 23:49:16 · 441 阅读 · 0 评论 -
hdu 1711
KMP入门题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1711很久以前就接触了KMP,但那时还没有做题,差不多都忘了.....Problem DescriptionGiven two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ....原创 2012-12-22 20:42:29 · 2001 阅读 · 0 评论 -
hdu 1754 线段树
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1754题目很基本,线段树的单点更新和区间求最值,前面有相似题,但TLE了几次,感觉没错啊,结果看了下别人的代码,差了个getchar(),原因是如果不加,则会把回车当成字符了,我勒个去...AC code:#include#includeusing namespace std;int原创 2012-11-27 02:21:44 · 422 阅读 · 0 评论 -
hdu 1247 Hat’s Words
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1247Problem DescriptionA hat’s word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary.You are to f原创 2012-12-29 06:15:58 · 1677 阅读 · 0 评论 -
hdu 1254 推箱子
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1254 Problem Description 推箱子是一个很经典的游戏.今天我们来玩一个简单版本.在一个M*N的房间里有一个箱子和一个搬运工,搬运工的工作就是把箱子推到指定的位置,注意,搬运工只能推箱子而不能拉箱子,因此如果箱子被推到一个角上(如图2)那么箱子就不能再被移动了,如果箱子原创 2012-12-20 03:01:18 · 988 阅读 · 0 评论 -
hdu 2203
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2203strstr函数: *strstr(s1,s2),返回s2在s1首次出现的位置.比如char s1[]="abc",char s2[]="b",则返回的指针指向"bc".AC code:#include#includeusing namespace std;#define M原创 2013-01-31 19:58:01 · 804 阅读 · 0 评论 -
hdu 2651
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2651题意:由春联求相似对数,由题目例子知,相似的特征是相邻相同字母的重复次数.AC code:#include using namespace std;int sum=0;struct TireTree { int num; TireTree *next[9];原创 2013-01-31 14:48:40 · 654 阅读 · 0 评论 -
hdu2579 BFS
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2579广搜,只不过可以往回走,所以标记数组也从二维数组变成三维数组。Ac code:#include #include #include using namespace std;int r,c,k;#define N 105bool step[N][N][12];ch原创 2013-05-27 18:54:52 · 873 阅读 · 0 评论