摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3460题意:一开始没有明白题意,看了好久,才明白,原来它是将一个单词打印出来后再在打印机里面删除字母,也就是说,如果单词前缀相同,则只需删除单词不相同的部分,再插入下一个单词不相同的部分。这样的话,可以用字典树,要是单词前缀相同,则在字典树上只有一个结点,那么,要是将最长的那个单词也删除了,则是对字典树上的结点插入一次再删除一次,还要输出n次,也就是2*numnode+n;但是最长的那个单词len不需要删除,则是2*numnode+n-len;#include<iostream>#include& 阅读全文
posted @ 2012-12-24 15:57 紫忆 阅读(421) 评论(0) 推荐(0) 编辑
摘要: http://acm.hust.edu.cn:8080/judge/problem/viewProblem.action?id=11157#include<iostream>#include<cstring>using namespace std;typedef struct tree { int num,flag; tree *next[26];}tree;tree *root;char s[1005][25];void creat(char str[]){ int len=strlen(str); tree *p=root,*q; for(int i=0;i< 阅读全文
posted @ 2012-12-24 14:01 紫忆 阅读(744) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4031思路:将防御和攻击分开,用树状数组统计攻击次数,再开一个数组统计成功防御次数。#include<iostream>using namespace std;struct { int num,count;}d[20005];int c[20005],n,str[20005][2];int lowbit(int x){ return x&(-x);}void updatac(int i,int j){ while(i<=n) { c[i]+=j; i+=lowbit(i); }}in 阅读全文
posted @ 2012-12-24 13:12 紫忆 阅读(357) 评论(0) 推荐(0) 编辑