03 2012 档案
转载一个写的挺不错的后缀树的文章
摘要:偶然看到一个后缀树的文章,觉得很有意思,转载一下:http://blog.csdn.net/g9yuayon/article/details/2574781不过不确定这个是不是原创。。在pongba的讨论组上看到一道Amazon的面试题:找出给定字符串里的最长回文。例子:输入XMADAMYX。则输出MADAM。这道题的流行解法是用后缀树(Suffix Tree)。这坨数据结构最酷的地方是用它能高效解决一大票复杂的字符串编程问题:在文本T里查询T是否包含子串P(复杂度同流行的KMP相当)。 文本T里找出最长重复子串。比如abcdabcefda里abc同da都重复出现,而最长重复子串是abc。 找 阅读全文
posted @ 2012-03-31 17:42 Bester 阅读(129) 评论(0) 推荐(0)
poj2590
摘要:#include#includeusing namespace std;int main(){double k,x[1000],y[1000];double a,b;int i,count,stepnum;cin>>count;for(i=0;i>x[i]>>y[i];for(i=0;i=k&&k>a*a)stepnum=2*a;else if(ka*a+a)stepnum=2*a+1;}//whilecout<<stepnum<<endl;}//forreturn 0;} 阅读全文
posted @ 2012-03-18 23:42 Bester 阅读(114) 评论(0) 推荐(0)
poj2328简单模拟
摘要:#includeusing namespace std;int main(){char str1[10];char str2[10];char ch;int turn;int tempint;int i;int guess[2];//0代表左边那个,1代表右边那个while(1){guess[0]=0;guess[1]=11;while(1){cin>>tempint; if(!tempint)return 0;cin>>str1;cin>>str2;if(strcmp(str1,"too")==0){if(strcmp(str2,&qu 阅读全文
posted @ 2012-03-18 23:40 Bester 阅读(153) 评论(0) 推荐(0)
poj3321 dfs+树状数组
摘要:很早以前做的了,拿出来记录下。#include#includeconst int N=100001;struct Node{int v;struct Node *next;Node(int n=0,struct Node *P=NULL){v=n;next=P;}}node[N];struct Range{int b,e;}range[N];bool visited[N];int c[N];int n;void Dfs(int p,int &id);inline int Lowbit(int x){return x&(-x);}void Modify(int i,int v); 阅读全文
posted @ 2012-03-18 23:39 Bester 阅读(131) 评论(0) 推荐(0)
poj3626广搜
摘要:#includeusing namespace std;#define MAXSIZE 10000class QElemType{public:int x,y;};class SQueue{public:int len;int front;//头指针,若队列不空,指向队列头元素int rear;//尾指针,若队列不空,指向队列尾元素的下一个位置QElemType base[MAXSIZE];int InitQueue();//初始化一个队伍int QueueLength();//求队伍长度int EnQueue(QElemType e);//插入元素为e的新的队尾元素int DeQueue(Q 阅读全文
posted @ 2012-03-18 23:37 Bester 阅读(102) 评论(0) 推荐(0)
poj3266一道典型线段树
摘要:因为最近想做的一个东西和区间统计有关,心血来潮玩了下线段树。 #includeusing namespace std;#define MAXNUMBER 1leftIndex=0;treeRoot->rightIndex=this->cowNumber-1;//Compare the Left Child and Right Child resultFindTreeMinAndMaxValue(treeRoot);return;}void SegmentTree::FindTreeMinAndMaxValue(TreeNode *tNode){//See if the node e 阅读全文
posted @ 2012-03-18 15:34 Bester 阅读(190) 评论(0) 推荐(0)
DataTemplate
摘要:.NET Framework 4.5.NET Framework 3.5.NET Framework 3.0 11 out of 17 rated this helpfulRate this topicThe WPF data templating model provides you with great flexibility to define the presentation of your data. WPF controls have built-in functionality to support the customization of data presentation. 阅读全文
posted @ 2012-03-15 12:58 Bester 阅读(232) 评论(0) 推荐(0)
如何遍历C# 中 Dictionary。
摘要:关键利用KeyValuePair。 定义一个Dictionary: Dictionary aggUpGroupPointDic = new Dictionary(); 遍历它: foreach (KeyValuePairkeyValuePair inaggDownGroupPointDic) { Console.WriteLine(“Point{0}’s position is ({1},{2})”,keyValuePair.Key,keyValuePair.Value.X,keyValuePair.Value.Y); } 阅读全文
posted @ 2012-03-08 17:16 Bester 阅读(147) 评论(0) 推荐(0)