
ACM_HDU
文章平均质量分 76
Cambridge
不做下一个谁,先做第一个我
展开
-
HDU-1247-Hats Words
HDU-1247-Hats Wordshttp://acm.hdu.edu.cn/showproblem.php?pid=1247还是字典树的题目,将每个单词分成两个单词即可,查找是否两个单词均在字典树中注意建树的时和之前略有区别,这题在插入单词时,只需记录单词结尾的节点,不需要记录一个单词的所有前缀#include#include#include#includeusing原创 2012-07-16 23:45:35 · 836 阅读 · 0 评论 -
HDU-1166-敌兵布阵(线段树)
HDU-1166-敌兵布阵http://acm.hdu.edu.cn/showproblem.php?pid=1166求区间的和,并可更新,线段树#include#include#include#define N 50005int num[N];struct cam{ int x; //起点 int y; //终点 int sum; //总数}list[N*原创 2012-07-19 08:10:19 · 916 阅读 · 0 评论 -
HDU-1166-敌兵布阵(树状数组)
HDU-1166-敌兵布阵(树状数组)http://acm.hdu.edu.cn/showproblem.php?pid=1166这题之前用线段树做的,现在用树状数组先简单说下树状数组吧如上图所示c1 = a1c2 = a1 + a2c3 = a3c4 = a1 + a2 + a3 + a4c5 = a5c6 = a5 + a6c7 = a7原创 2012-07-22 07:57:14 · 4734 阅读 · 0 评论 -
HDU-4107-Gangster
HDU-4107-Gangsterhttp://acm.hdu.edu.cn/showproblem.php?pid=4107线段树的成段更新,这题可以记录一个区间的最大值和最小值,若一个区间的最大值小于p,则增量增加c,若区间的最小值大于等于p,则增量增加2*c,G++超时,C++过了#include#include#include#include#define N 200原创 2012-08-08 10:21:23 · 838 阅读 · 0 评论 -
HDU-1542-Atlantis
HDU-1542-Atlantishttp://acm.hdu.edu.cn/showproblem.php?pid=1542用线段树求矩形面积的并,模仿别人的代码写的,还要好好研究啊#include#include#include#include#includeusing namespace std;struct node{ int l; int r; int原创 2012-08-07 17:27:02 · 2525 阅读 · 0 评论 -
HDU-1800-Flying to the Mars
HDU-1800-Flying to the Marshttp://acm.hdu.edu.cn/showproblem.php?pid=1800字典树,每一个节点有10个叶子节点,注意前缀的0要去掉#include#include#includeusing namespace std;int Max;struct node{ int count; node *chil原创 2012-08-07 16:36:31 · 1001 阅读 · 0 评论 -
HDU-1671-Phone List
HDU-1671-Phone Listhttp://acm.hdu.edu.cn/showproblem.php?pid=1671字典树,判断是否有某个数字是另一个数字的前缀,注意123不是123的前缀,建树之后要删除节点,否则会Memory LimitExceeded写的比较麻烦,分两种情况,一是先出现123,再出现1234,;二是先出现1234,再出现123#include#原创 2012-08-07 20:09:08 · 1037 阅读 · 0 评论 -
HDU-1075-What Are You Talking About
HDU-1075-What Are You Talking Abouthttp://acm.hdu.edu.cn/showproblem.php?pid=1075字典树#include#include#include#includeusing namespace std;struct node{ int count; node *childs[26]; char tr原创 2012-08-09 14:58:43 · 733 阅读 · 0 评论 -
HDU-1305-Immediate Decodability
HDU-1305-Immediate Decodabilityhttp://acm.hdu.edu.cn/showproblem.php?pid=1305字典树水题,判断前缀#include#include#include#includeusing namespace std;struct node{ int count; node *childs[2]; node(原创 2012-08-09 15:50:36 · 1610 阅读 · 0 评论 -
HDU-3397-Sequence operation
HDU-3397-Sequence operationhttp://acm.hdu.edu.cn/showproblem.php?pid=3397线段树,对区间的多个操作#include#include#include#includeusing namespace std;#define N 100010struct cam{ int x; int y; int l原创 2012-08-08 14:52:32 · 1303 阅读 · 1 评论 -
HDU-3371-Connect the Cities
HDU-3371-Connect the Citieshttp://acm.hdu.edu.cn/showproblem.php?pid=3371最小生成树,已知有些节点已经相连#include#include#includestruct cam{ int x; int y; int len;}list[25005*3];int f[505];int n,m,k;原创 2012-08-11 19:52:42 · 861 阅读 · 0 评论 -
HDU-1596-find the safest road
HDU-1596-find the safest roadhttp://acm.hdu.edu.cn/showproblem.php?pid=1596SPFA算法#include#include#includeusing namespace std;int n,m,st,ed,front,rear;double mat[1005][1005],dis[1005];int原创 2012-08-13 13:56:43 · 865 阅读 · 0 评论 -
11年成都网络赛
今天把去年成都的网络赛做了一下,去年是一题不会哇,现在也挺吃力,还有几题不会,有空再来看Attackhttp://acm.hdu.edu.cn/showproblem.php?pid=4031树状数组,这题树状数组节点n记录的是wall[n]和wall[n-1]被炮击的差#include#include#include#includeusing namespace st原创 2012-08-01 23:48:45 · 2674 阅读 · 0 评论 -
HDU-2795-Billboard
HDU-2795-Billboardhttp://acm.hdu.edu.cn/showproblem.php?pid=2795线段树,建树时要注意范围#include#include#include#includeusing namespace std;#define N 200005int h,w;struct cam{ int x; int y; int l原创 2012-08-06 11:46:09 · 827 阅读 · 0 评论 -
HDU-4027-Can you answer these queries
HDU-4027-Can you answer these querieshttp://acm.hdu.edu.cn/showproblem.php?pid=4027线段树成段更新,n比较小,更新到每个叶子节点,注意1开根号后仍是1,不需要再更新#include#include#include#include#includeusing namespace std;typed原创 2012-08-06 16:14:15 · 629 阅读 · 0 评论 -
HDU-1251-统计难题
HDU-1251-统计难题http://acm.hdu.edu.cn/showproblem.php?pid=1251基本的字典树,字典树又称单词查找树,Trie树,是一种树形结构,是一种哈希树的变种。典型应用是用于统计,排序和保存大量的字符串(但不仅限于字符串),所以经常被搜索引擎系统用于文本词频统计。它的优点是:利用字符串的公共前缀来节约存储空间,最大限度地减少无谓的字符串比较,查询效原创 2012-07-16 16:55:13 · 5867 阅读 · 4 评论 -
HDU-2846-Repository
HDU-2846-Repositoryhttp://acm.hdu.edu.cn/showproblem.php?pid=2846题意是给出一些模式串,再给出几个询问,询问给出的字符串在多少个模式串中出现比如字符串abc所含的字串有a,ab,abc,b,bc,c可用字典树解决,字典树能很好的处理前缀出现的次数,所以可将模式串分解,依次插入需要注意的是对于同一个模式串的不同子串可原创 2012-07-17 09:48:35 · 1890 阅读 · 0 评论 -
HDU-1272-小希的迷宫
HDU-1272-小希的迷宫http://acm.hdu.edu.cn/showproblem.php?pid=1272基本的并查集#include#includeusing namespace std;#define N 100010int f[N];int mark[N];int find(int x){ int r=x; while(f[r]!=r) r=f[原创 2012-08-02 15:08:18 · 908 阅读 · 0 评论 -
HDU-1598-find the most comfortable road
HDU-1598-find the most comfortable roadhttp://acm.hdu.edu.cn/showproblem.php?pid=1598并查集加贪心#include#include#include#includeusing namespace std;#define N 1010#define INF 0x7fffffffstruct c原创 2012-08-02 16:40:18 · 810 阅读 · 0 评论 -
HDU-1711-Number Sequence
HDU-1711-Number Sequencehttp://acm.hdu.edu.cn/showproblem.php?pid=1711KMP模版#include#include#includeusing namespace std;#define N 1000005#define M 10005int a[N],b[M],nextt[M];int n,m;voi原创 2012-08-03 14:42:17 · 598 阅读 · 0 评论 -
HDU-1754-I Hate It
HDU-1754-I Hate Ithttp://acm.hdu.edu.cn/showproblem.php?pid=1754查询区间的最大值,并可以更新线段树即可,如图为区间[1,5]的线段树#include#include#include#define N 200005int num[N];struct cam{ int x; //起点 int原创 2012-07-18 21:52:06 · 679 阅读 · 0 评论 -
HDU-3635-Dragon Balls
HDU-3635-Dragon Ballshttp://acm.hdu.edu.cn/showproblem.php?pid=3635并查集,路径压缩来更新转移的次数#include#include#include#includeusing namespace std;#define N 10005struct cam{ int f; int num; int cn原创 2012-08-03 10:41:27 · 749 阅读 · 0 评论 -
HDU-3074-Multiply game
HDU-3074-Multiply gamehttp://acm.hdu.edu.cn/showproblem.php?pid=3074求区间元素的乘积,可以更新元素,线段树即可#include#include#include#define Mod 1000000007#define N 50005int num[N];struct cam{ int x; //起点原创 2012-07-18 23:34:38 · 1046 阅读 · 0 评论 -
HDU-3790-最短路径问题
HDU-3790-最短路径问题http://acm.hdu.edu.cn/showproblem.php?pid=3790单源最短路劲,更新路劲时要更新花费#include#include#include#includeusing namespace std;#define INF 0x7fffffffint n,m;int map[1005][1005];int co原创 2012-08-05 09:45:46 · 4689 阅读 · 1 评论 -
HDU-1698-Just a Hook
HDU-1698-Just a Hookhttp://acm.hdu.edu.cn/showproblem.php?pid=1698还是成段更新线段树#include#include#include#define N 100005struct cam{ int x; int y; int sum; int val;}list[N*4];void build(int原创 2012-07-20 17:32:51 · 556 阅读 · 0 评论 -
HDU-1394-Minimum Inversion Number
HDU-1394-Minimum Inversion Numberhttp://acm.hdu.edu.cn/showproblem.php?pid=1394题意是给出n个数,求其逆序数,并每次将第一个数移至最后,再求其逆序数,求这n个排列中逆序数最小的一个逆序数的简单定义:The inversion number of a givennumber sequence a1, a2, .原创 2012-07-21 10:05:45 · 773 阅读 · 0 评论 -
HDU-4325-Flowers
HDU-4325-Flowershttp://acm.hdu.edu.cn/showproblem.php?pid=4325成段更新加离散化线段树这题做了快有一天了。。。。各种问题啊,开始建树时没有把查询的节点加入树中,结果在查询时发现很多节点的信息丢失了,纠结了半天去看了下别人的代码,原来建树时就应把查询的节点加入,在做离散化时,将hash数组开到10^9,又超内存了,通不过编译,囧原创 2012-08-04 16:36:02 · 1226 阅读 · 0 评论 -
HDU-4287-Intelligent IME
HDU-4287-Intelligent IMEhttp://acm.hdu.edu.cn/showproblem.php?pid=4287开始用字典树+深搜,超时。。。。后来发现题目最多6位数,可将字符串转化成对应的数字,然后hash即可TLE的代码#include #include #include #include using namespace std;原创 2012-09-10 08:30:10 · 2445 阅读 · 1 评论