锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品成人久久久,性做久久久久久免费观看,久久露脸国产精品http://www.shnenglu.com/syhd142/articles/138223.htmlFuckerFuckerSun, 09 Jan 2011 16:11:00 GMThttp://www.shnenglu.com/syhd142/articles/138223.htmlhttp://www.shnenglu.com/syhd142/comments/138223.htmlhttp://www.shnenglu.com/syhd142/articles/138223.html#Feedback0http://www.shnenglu.com/syhd142/comments/commentRss/138223.htmlhttp://www.shnenglu.com/syhd142/services/trackbacks/138223.html妯℃澘棰?/div>
#include <stdio.h>
#include 
<string.h>
#include 
<math.h>
#include 
<vector>
#include 
<algorithm>
#include 
<queue>
using namespace std;

#define KIND 128
#define M 10010

struct node
{
    node 
*fail;
    node 
*next[KIND];
    
int id;
    node ()
        {
            fail 
= NULL;
            id 
= 0;
            memset(next, 
0sizeof(next));
        }
};

char ch[M];
queue
<node *> q;
vector
<int> g;

void insert(node *&root, char *ch, int id)
{
    node 
*= root;
    
int i = 0, t;
    
while(ch[i])
    {
        t 
= ch[i] - 31;
        
if(!p->next[t]) p->next[t] = new node();
        p 
= p->next[t];
        i
++;
    }
    p
->id = id;
}

void AC(node *&root)
{
    q.push(root);
    
while(!q.empty())
    {
        node 
*= NULL;
        node 
*= q.front();
        q.pop();
        
for(int i = 0; i < KIND; i++)
        {
            
if(t->next[i])
            {
                p 
= t->fail;
                
while(p)
                {
                    
if(p->next[i])
                    {
                        t
->next[i]->fail = p->next[i];
                        
break;
                    }
                    p 
= p->fail;
                }
                
if(!p) t->next[i]->fail = root;
                q.push(t
->next[i]);
           }
        }
    }
}

bool query(node *&root, char *ch, int count)
{
    g.clear();
    
int i = 0, t, top = 0, flag = 0;
    node 
*= root, *tmp;
    
while(ch[i])
    {
        t 
= ch[i] - 31;
        
while(!p->next[t] && p != root) p = p->fail;
        p 
= p->next[t];
        
if(!p) p = root;
        tmp 
= p;
        
while(tmp != root && tmp->id)
        {
            flag 
= 1;
            g.push_back(tmp
->id);
            tmp 
= tmp->fail;
        }
        i
++;
    }
    
if(!flag) return false;
    sort(g.begin(), g.end());
    printf(
"web %d:", count);
    printf(
" %d", g[0]);
    
for(int i = 1; i < g.size(); i++)
    {
        
if(g[i] != g[i - 1])
        printf(
" %d", g[i]);
    }
    printf(
"\n");
    
return true;
}

int main()
{
    
int n, total;
    
while(~scanf("%d"&n))
    {
        node 
*root = new node();
        total 
= 0;
        
for(int i = 0; i < n; i++)
        {
            scanf(
"%s", ch);
            insert(root, ch, i 
+ 1);
        }
        AC(root);
        scanf(
"%d"&n);
        
for(int i = 0; i < n; i++)
        {
            scanf(
"%s", ch);
            
if(query(root, ch, i + 1)) total++;
        }
        printf(
"total: %d\n", total);
    }
    
return 0;
}


Fucker 2011-01-10 00:11 鍙戣〃璇勮
]]>
HDU 2222 Keywords Searchhttp://www.shnenglu.com/syhd142/articles/138031.htmlFuckerFuckerWed, 05 Jan 2011 09:38:00 GMThttp://www.shnenglu.com/syhd142/articles/138031.htmlhttp://www.shnenglu.com/syhd142/comments/138031.htmlhttp://www.shnenglu.com/syhd142/articles/138031.html#Feedback0http://www.shnenglu.com/syhd142/comments/commentRss/138031.htmlhttp://www.shnenglu.com/syhd142/services/trackbacks/138031.html鐢變簬璁烘枃鐨勯渶瑕侊紝鐪嬩簡涓涓婣C鑷姩鏈虹殑鍘熺悊錛屾劅瑙夊氨鏄痶rie鏍?kmp錛岃繖涓や釜鍗曠嫭閮藉啓榪囷紝
浣嗘槸鍚堝湪涓璧瘋繕鐪熸病鍐欒繃錛屽弬鐓х綉涓婄殑浠g爜鍐欎簡涓涓狧DU涓婄殑棰樼洰錛屾按鐨勫緢錛屽叆闂ㄧ駭鍒殑銆?/div>
#include <stdio.h>
#include 
<stdlib.h>
#include 
<string.h>

#define N 500005
#define KIND 26

struct node
{
    node 
*fail;
    node 
*next[KIND];
    
int count;
    node()
        {
            fail 
= NULL;
            count 
= 0;
            memset(next, 
0sizeof(next));
        }
}
*queue[N];

void insert(node *root, char *str)
{
    
int i = 0, index;
    node 
*= root;
    
while(str[i])
    {
        index 
= str[i] - 'a';
        
if(p->next[index] == NULL) p->next[index] = new node();
        p 
= p->next[index];
        i
++;
    }
    p
->count++;
}

void build(node *root)
{
    
int front = 0, rear = 0;
    root
->fail = NULL;
    queue[rear
++= root;
    
while(front < rear)
    {
        node 
*tmp = queue[front++];
        node 
*= NULL;
        
for(int i = 0; i < KIND; i++)
        {
            
if(tmp->next[i])
            {            
                p 
= tmp->fail;
                
while(p)
                {
                    
if(p->next[i])
                    {
                        tmp
->next[i]->fail = p->next[i];
                        
break;
                    }
                    p 
= p->fail;
                }
                
if(!p) tmp->next[i]->fail = root;
                queue[rear
++= tmp->next[i];
            }
        }
    }
}

char str[1000005];

int query(node *root)
{
    
int i = 0, ans = 0, index;
    node 
*= root, *tmp;
    
while(str[i])
    {
        index 
= str[i] - 'a';
        
while(p->next[index] == NULL && p != root) p = p->fail;
        p 
= p->next[index];
        
if(!p) p = root;
        tmp 
= p;
        
while(tmp != root)
        {
            ans 
+= tmp->count;
            tmp
->count = 0;
            tmp 
= tmp->fail;
        }
        i
++;
    }
    
return ans;
}

int main()
{
    
int t, nkey, ans;
    
char key[100];
    scanf(
"%d"&t);
    
while(t--)
    {
        node 
*root = new node();
        scanf(
"%d"&nkey);
        
for(int i = 0; i < nkey; i++)
        {
            scanf(
"%s", key);
            insert(root, key);
        }
        build(root);
        scanf(
"%s", str);
        ans 
= query(root);
        printf(
"%d\n", ans);
    }
    
return 0;
}


Fucker 2011-01-05 17:38 鍙戣〃璇勮
]]>UVA 417 Word Indexhttp://www.shnenglu.com/syhd142/articles/128806.htmlFuckerFuckerWed, 06 Oct 2010 11:40:00 GMThttp://www.shnenglu.com/syhd142/articles/128806.htmlhttp://www.shnenglu.com/syhd142/comments/128806.htmlhttp://www.shnenglu.com/syhd142/articles/128806.html#Feedback0http://www.shnenglu.com/syhd142/comments/commentRss/128806.htmlhttp://www.shnenglu.com/syhd142/services/trackbacks/128806.html棰樼洰寰堢畝鍗曪紝鐢熸垚瀛楁瘝欏哄簭鐨勬椂鍊欎笉浼氬紕錛屼唬鐮佽兘鍔涜繕鏄笉琛屻?/span>
#include <stdio.h>
#include 
<string>
#include 
<map>
using namespace std;

char word[27= "abcdefghijklmnopqrstuvwxyz";
bool mk[27]; 
map
<stringint> hash;
int num;

void build(int pos, int deep)
{
    
if(!deep)
    {
        num
++;
        
char tmp[6];
        
int len = 0;
        
for(int i = 0; i < 26; i++)
        {
            
if(mk[i]) tmp[len++= word[i];
        }
        tmp[len] 
= 0;
    
//    printf("%s\n", tmp);
    
//    system("pause");
        hash[(string)tmp] = num;
        
return;
    }
    
if(pos >= 26return;
    mk[pos] 
= 1;
    build(pos 
+ 1, deep - 1);
    mk[pos] 
= 0;
    build(pos 
+ 1, deep);
}

int main()
{
    num 
= 0;
    
for(int i = 1; i < 6; i++) build(0, i);
    
char data[6];
    
while(gets(data)) printf("%d\n", hash[data]);
    
return 0;



Fucker 2010-10-06 19:40 鍙戣〃璇勮
]]>
UVA 10391 Compound Wordshttp://www.shnenglu.com/syhd142/articles/119511.htmlFuckerFuckerTue, 06 Jul 2010 16:33:00 GMThttp://www.shnenglu.com/syhd142/articles/119511.htmlhttp://www.shnenglu.com/syhd142/comments/119511.htmlhttp://www.shnenglu.com/syhd142/articles/119511.html#Feedback0http://www.shnenglu.com/syhd142/comments/commentRss/119511.htmlhttp://www.shnenglu.com/syhd142/services/trackbacks/119511.html棰樻剰錛氱粰瀹氫竴涓瓧鍏革紝瑕佷綘鍒ゆ柇鍏朵腑鐨勪換鎰忎袱涓崟璇嶆槸鍚﹀彲浠ョ粍鎴愬彟涓涓崟璇嶃?/span>
瑙f硶錛歵rie鏍戯紝璁板綍鎵鏈夌殑鍗曡瘝錛岀劧鍚庡啀瀵規瘡涓。嬈℃灇涓懼垎闅旂偣銆傜濂囩殑鏄垜閲婃斁鍐呭瓨灝盧E錛屼笉閲婃斁灝盇浜嗐傛病鎼炴噦銆?/span>
#include <stdio.h>
#include 
<stdlib.h>
#include 
<string.h>

#define N 50005
#define KIND 26

struct TreeNode
{
    
int count;
    TreeNode 
*next[KIND];
    TreeNode()
    {
        count 
= 0;
        memset(next, 
0sizeof(next));
    }
}
*root;

char data[N][105], data1[105], data2[105];

void Insert(char *s)
{
    TreeNode 
*= root;
    
for(; *s; s++)
    {
        
int t = (*s) - 'a';
        
if(NULL == r->next[t])
        {
            r
->next[t] = new TreeNode();
        }
        r 
= r->next[t];
    }
    r
->count = 1;
}

bool Find(char *s)
{
    
int count = 0;
    TreeNode 
*= root;
    
for(; *s; s++)
    {
        
int t = (*s) - 'a';
        
if(r->next[t] == NULL) return false;
        r 
= r->next[t];
    }
    
if(r->count) return true;
    
return false;
}

void Release(TreeNode *p)
{
    
for(int i = 0; i < KIND; i++)
    {
        
if(p->next[i]) Release(p);
    }
    delete p;
}

int main()
{
    
int n = 0;
    root 
= new TreeNode();
    
while(scanf("%s", data[n]) != EOF)
    {
        Insert(data[n]);
        n
++;
    }
    
for(int i = 0; i < n; i++)
    {
        
int l = strlen(data[i]);
        
for(int j = 1; j < l; j++
        {
            
int k;
            
for(k = 0; k < j; k++)
                data1[k] 
= data[i][k];
            data1[k] 
= '\0';
            
for(k = j; k < l; k++)
                data2[k 
- j] = data[i][k];
            data2[k 
- j] = '\0';
        
//    strncpy(data1, data[i], j);
        
//    strncpy(data2, data[i] + j, l - j + 1);
        
//    puts(data1);puts(data2);
            if(Find(data1) && Find(data2))
            {
                puts(data[i]);
                
break;
            }
        }
    }
    
//Release(root);
    
return 0;
}


Fucker 2010-07-07 00:33 鍙戣〃璇勮
]]>
PKU 3630 Phone Listhttp://www.shnenglu.com/syhd142/articles/119316.htmlFuckerFuckerSun, 04 Jul 2010 14:15:00 GMThttp://www.shnenglu.com/syhd142/articles/119316.htmlhttp://www.shnenglu.com/syhd142/comments/119316.htmlhttp://www.shnenglu.com/syhd142/articles/119316.html#Feedback0http://www.shnenglu.com/syhd142/comments/commentRss/119316.htmlhttp://www.shnenglu.com/syhd142/services/trackbacks/119316.html棰樻剰錛氱粰瀹歯涓暱搴︿笉瓚呰繃10鐨勭數璇濆彿鐮侊紝姹傛槸鍚︽湁鐢佃瘽鍙風爜鏄彟涓涓殑鍓嶇紑銆?/span>
瑙f硶錛歍rie鏍戯紝浠g爜鑳藉姏鐩寸嚎涓嬮檷鍟娿傘傝繖涔堢畝鍗曠殑濂藉啓榪欎箞涔呫?/span>
#include <stdio.h>
#include 
<string.h>

#define N 10005
#define KIND 10

struct TreeNode
{
    TreeNode 
*next[KIND];
}table[N 
* 10], root;


char data[N][15];
int sp;

void Insert(char *data)
{
    TreeNode 
*= &root;
    
for(; *data; data++)
    {
        
int t = *data - '0';
        
if(NULL == r->next[t])
        {
            r
->next[t] = &table[sp];
            memset(table[sp].next, 
0sizeof(table[sp].next));
            sp
++;
        }
        r 
= r->next[t];
    }
}

bool Find(char *data)
{
    TreeNode 
*= &root;
    
for(; *data; data++)
    {
        
int t = *data - '0';
        r 
= r->next[t];
    }
    
for(int i = 0; i < KIND; i++)
        
if(r->next[i]) return 1;
    
return 0;
}

int main()
{
    
int n, t;
    
bool flag;
    scanf(
"%d"&t);
    
while(t--)
    {
        scanf(
"%d"&n);
        memset(root.next, 
0sizeof(root.next));
        sp 
= 0;
        
for(int i = 0; i < n; i++)
        {
            scanf(
"%s"&data[i]);
            Insert(data[i]);
        }
        flag 
= 1;
        
for(int i = 0; i < n; i++)
        {
            
if(Find(data[i]))
            {
                flag 
= 0;
                
break;
            }
        }
        
if(!flag) puts("NO");
        
else puts("YES");
    }
    
return 0;
}


Fucker 2010-07-04 22:15 鍙戣〃璇勮
]]>
久久性生大片免费观看性| 久久久久久久精品成人热色戒 | 韩国无遮挡三级久久| 国产欧美久久久精品| 国产精品免费久久| 欧美亚洲另类久久综合婷婷| 久久国产欧美日韩精品免费| 久久99这里只有精品国产| 久久综合给合久久狠狠狠97色69| 91精品国产91久久综合| 久久精品无码一区二区日韩AV| 一个色综合久久| 国产叼嘿久久精品久久| 国内精品久久久久影院薰衣草| 国产精品久久久久久搜索| 亚洲Av无码国产情品久久| 久久精品国产亚洲网站| 久久久久久久久久久| 久久久久久久国产免费看| 韩国免费A级毛片久久| 一本大道久久东京热无码AV| 狠狠干狠狠久久| 久久午夜无码鲁丝片秋霞| 久久九九久精品国产免费直播| 日韩人妻无码精品久久免费一| 亚洲另类欧美综合久久图片区| 久久国产精品-国产精品| 色欲综合久久躁天天躁蜜桃 | 久久人妻AV中文字幕| 久久久久女教师免费一区| 91精品国产乱码久久久久久| 久久夜色精品国产亚洲| 欧美久久久久久精选9999| 亚洲国产精品久久久久婷婷老年| 久久久久亚洲精品天堂| 精品综合久久久久久98| 人妻无码αv中文字幕久久琪琪布 人妻无码精品久久亚瑟影视 | 久久91精品综合国产首页| 久久久久久久99精品免费观看| 久久精品国产99久久无毒不卡| 国产成人无码精品久久久性色|