摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3518首先关于后缀数组的详细介绍请参考这篇文章后缀数组——处理字符串的有力工具分析:下边的代码是参看网上的一段代码http://blog.163.com/just_gogo/blog/static/19143906520118595853521/尚在研习中,分享给大家参考参考。#include <cstdio>#include <cstring>#include <algorithm>#define maxn 20000using namespace std;in
阅读全文
摘要:题目链接 : http://acm.hdu.edu.cn/showproblem.php?pid=1671分析:字典树题目变种,这里的字典树指的是0--9的变化。基本原理没有大的变化就是字典树查找。(1)这道题就是找到这组电话号码中是否有 某个电话号码的前n-1个子串是否由其他的电话号码组成。是就输出NO,否就输出YES.题目大意很简单,字典树时的使用就是套模板,做这种题第一次最好自己写一遍模板,以后自己可以直接使用自己的模板。我的字典树模板见 字典树模板。#include <iostream>#include <cstdio>#include <cstring&
阅读全文
摘要:题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1251分析:关于字典树的题目似乎都有一个普通适用性的模板,有时只是稍加改动来满足临时的要求,我的一个简单的模板#define MAXNUM 26//定义字典树结构体typedef struct Trie{ bool flag;//从根到此是否为一个单词 Trie *next[MAXNUM];}Trie;//声明一个根Trie *root;//初始化该根void init(){ root = (Trie *)malloc(sizeof(Trie)); root->flag=f...
阅读全文
摘要:题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1247分析:这道题可以使用stl中的map直接来解决,也可以使用字典树来解决,当然字典树的效率会更高(1)stl解法不做过多的解释,这里有网上一个stl解法的链接 http://hi.baidu.com/mingyiyiyi_3/item/25835459866641494eff20f5(2)字典树解法,字典树 (详细看链接解释)定义一个字典树结构体typedef struct Trie{ bool flag;//从根到此是否为一个单词 Trie *next[MAXNUM];}Trie;字...
阅读全文
摘要:How Many Answers Are WrongTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1210Accepted Submission(s): 486Problem DescriptionTT and FF are ... friends. Uh... very very good friends -________-bFF is a bad boy, he is always wooing TT to play the follo
阅读全文
摘要:Zjnu StadiumTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 626Accepted Submission(s): 261Problem DescriptionIn 12th Zhejiang College Students Games 2007, there was a new stadium built in Zhejiang Normal University. It was a modern stadium which c.
阅读全文
摘要:Junk-Mail FilterTime Limit: 15000/8000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 169 Accepted Submission(s): 58 Problem Description Recognizing junk mails is a tough task. The method used here consists of two steps:1) Extract the common character...
阅读全文
摘要:Dragon BallsTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1271Accepted Submission(s): 516Problem DescriptionFive hundred years later, the number of dragon balls will increase unexpectedly, so it's too difficult for Monkey King(WuKong) to gath
阅读全文
摘要:find the most comfortable roadTime Limit: 1000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1662Accepted Submission(s): 683Problem DescriptionXX星有许多城市,城市之间通过一种奇怪的高速公路SARS(Super Air Roam Structure---超级空中漫游结构)进行交流,每条SARS都对行驶在上面的Flycar限制了固定的Speed,同时XX星人对 Flycar的“舒适
阅读全文
摘要:Rank of TetrisTime Limit: 1000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2771Accepted Submission(s): 756Problem Description自从Lele开发了Rating系统,他的Tetris事业更是如虎添翼,不久他遍把这个游戏推向了全球。为了更好的符合那些爱好者的喜好,Lele又想了一个新点子:他将制作一个全球Tetris高手排行榜,定时更新,名堂要比福布斯富豪榜还响。关于如何排名,这个不用说都知道是根据R
阅读全文
摘要:Triangle LOVETime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1387Accepted Submission(s): 584Problem DescriptionRecently, scientists find that there is love between any of two people. For example, between A and B, if A don’t love B, then B must love
阅读全文
摘要:Is It A Tree?Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 421 Accepted Submission(s): 157 ...
阅读全文
摘要:A Bug's LifeTime Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 364 Accepted Submission(s): 140 Problem Description Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they featur...
阅读全文
摘要:Sequence twoTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 98 Accepted Submission(s): 46 Problem Description Search is important in the acm algorithm. When you want to solve a problem by using the search method, try to cut is ver...
阅读全文
摘要:Sequence oneTime Limit: 6000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 294Accepted Submission(s): 97Problem DescriptionSearch is important in the acm algorithm. When you want to solve a problem by using the search method, try to cut is very important.Now give
阅读全文
摘要:Tempter of the BoneTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 615 Accepted Submission(s): 219 Problem Description The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze...
阅读全文
摘要:Sudoku KillerTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 481 Accepted Submission(s): 176 Problem Description 自从2006年3月10日至11日的首届数独世界锦标赛以后,数独这项游戏越来越受到人们的喜爱和重视。据说,在2008北京奥运会上,会将数独列为一个单独的项目进行比赛,冠军将有可能获得的一份巨大的奖品———HDU免费七日游外加lcy亲笔签...
阅读全文
摘要:SticksTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3582Accepted Submission(s): 903Problem DescriptionGeorge took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the o
阅读全文
摘要:Prime Ring ProblemTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 14715Accepted Submission(s): 6720Problem DescriptionA ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of nu
阅读全文
摘要:Kill the monsterTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 502Accepted Submission(s): 345Problem DescriptionThere is a mountain near yifenfei’s hometown. On the mountain lived a big monster. As a hero in hometown, yifenfei wants to kill it. No
阅读全文