随笔分类 -  字符串

poj 1226
摘要:水题。代码:#include<iostream>#include<string.h>#include<fstream>using namespace std;char x[101][101];char c[101];char str[101],str1[101];int len=101,n;void read(){// ifstream cin("in.txt"); int i,j,k,m,s,t; cin>>k; while(k--) { cin>>n; len=101; for(i=0;i<n;i++) 阅读全文

posted @ 2011-04-19 15:47 宇宙吾心 阅读(633) 评论(0) 推荐(0)

poj 1816
摘要:trie树上的搜索,数据太阴了,模式串有重复的。代码:#include<iostream>#include<fstream>using namespace std;struct e{ int a; e *next;};struct { int p[60]; e end;}trie[600001];int m,n;int hash[128];int state=1;long long s;int v[100001];int f;void build(char c[]){ int i,j=0,k; for(i=1;;) { if(trie[i].p[hash[c[j]]]= 阅读全文

posted @ 2011-03-09 17:14 宇宙吾心 阅读(346) 评论(0) 推荐(0)

poj 1204
摘要:ac自动机的题。代码:#include <iostream>using namespace std;const int N=1010;int n,m,w;struct trie{ int nxt[27]; int num,fl,id,len;}ac[N*N];int q[N*N];char a[N][N],c[N];int idx;struct nod{ int x,y; char c;}ans[N];void add(char c[],int id,int len){ int p=0; for(int i=0;c[i];i++) { int x=c[i]-'A'; 阅读全文

posted @ 2011-03-05 19:43 宇宙吾心 阅读(420) 评论(2) 推荐(0)

poj 1200
摘要:题目比较简单,hash即可。可惜犯了个低级错误,for(i=0;i+m-1<n;i++)(这里原来写错了!!)。 阅读全文

posted @ 2011-03-04 14:16 宇宙吾心 阅读(232) 评论(0) 推荐(0)

导航