亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

Oulipo POJ - 3461

2019-11-14 10:40:55
字體:
來源:轉載
供稿:網友

The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter'e'. He was a member of the Oulipo group. A quote from the book:

Tout avait Pair normal, mais tout s’affirmait faux. Tout avait Fair normal, d’abord, puis surgissait l’inhumain, l’affolant. Il aurait voulu savoir où s’articulait l’association qui l’unissait au roman : stir son tapis, assaillant à tout instant son imagination, l’intuition d’un tabou, la vision d’un mal obscur, d’un quoi vacant, d’un non-dit : la vision, l’avision d’un oubli commandant tout, où s’abolissait la raison : tout avait l’air normal mais…

Perec would PRobably have scored high (or rather, low) in the following contest. People are asked to write a perhaps even meaningful text on some subject with as few occurrences of a given “Word” as possible. Our task is to provide the jury with a program that counts these occurrences, in order to obtain a ranking of the competitors. These competitors often write very long texts with nonsense meaning; a sequence of 500,000 consecutive'T's is not unusual. And they never use spaces.

So we want to quickly find out how often a word, i.e., a given string, occurs in a text. More formally: given the alphabet {'A','B','C', …,'Z'} and two finite strings over that alphabet, a wordW and a textT, count the number of occurrences ofW inT. All the consecutive characters of W must exactly match consecutive characters ofT. Occurrences may overlap.

Input

The first line of the input file contains a single number: the number of test cases to follow. Each test case has the following format:

One line with the word W, a string over {'A','B','C', …,'Z'}, with 1 ≤ |W| ≤ 10,000 (here |W| denotes the length of the string W).One line with the text T, a string over {'A','B','C', …,'Z'}, with |W| ≤ |T| ≤ 1,000,000.Output

For every test case in the input file, the output should contain a single number, on a single line: the number of occurrences of the wordW in the textT.

Sample Input
3BAPCBAPCAZAAZAZAZAVERDIAVERDXIVYERDIANSample Output
130KMP問題。。。。不過和KMP稍有不同,這個題要求計算次數而不是匹配成功就可以,所以next數組多求一位。AC代碼:
#include <iostream>#include <stdio.h>#include <string.h>#include <math.h>#include <algorithm>using namespace std;int lent,lenp,next[10005];char p[10005],t[1000005];void getnext(){    int i=0,j=-1;    next[0]=-1;    while(i!=lenp)    {        if(j==-1||p[i]==p[j])        {            next[++i]=++j;        }        else        {            j=next[j];        }    }}int KMP(){    int i=0,j=0,c=0;    while(i!=lent&&j!=lenp)    {        if(t[i]==p[j]||j==-1)        {            ++i,++j;        }        else        {            j=next[j];        }        if(j==lenp)        {            c++;            j=next[j];        }    }    return c;}int main(){    int n,i,k,j,ans;    scanf("%d",&n);    getchar();    while(n--)    {        scanf("%s%s",p,t);        lent=strlen(t);        lenp=strlen(p);        getnext();        ans=KMP();        printf("%d/n",ans);    }    return 0;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
国产精品视频区1| 91久久精品国产91久久性色| 欧美精品福利在线| 国产噜噜噜噜噜久久久久久久久| 欧美日韩国产在线| 欧美中在线观看| 91久久久久久国产精品| 成人免费网站在线观看| 91丝袜美腿美女视频网站| 亚洲人成自拍网站| 国产97色在线| 欧美精品18videos性欧美| 91在线观看免费网站| 亚洲精品一区二区三区不| 高清亚洲成在人网站天堂| 色偷偷亚洲男人天堂| 亚洲一区二区三区sesese| 欧美在线免费看| 亚洲色图激情小说| 国产成人精品免高潮在线观看| 日韩中文字幕免费看| 一区二区三区无码高清视频| 这里只有精品久久| 久久久久久久久电影| 中文字幕日韩高清| 91成人天堂久久成人| 中文字幕在线视频日韩| 色999日韩欧美国产| 欧美一级淫片播放口| 不卡av在线播放| 亚洲xxxx妇黄裸体| 日韩美女在线看| 亚洲激情视频在线播放| 亚洲欧美精品一区二区| 日本老师69xxx| 国产日韩精品入口| 国内伊人久久久久久网站视频| 日本久久久久久| 欧美另类xxx| 国产成人在线精品| 青青草原一区二区| 在线丨暗呦小u女国产精品| 亚洲大胆人体av| 精品视频一区在线视频| 欧美日韩亚洲一区二区三区| 国产日韩精品在线观看| 国产成人精品综合| 欧美高清视频在线播放| 国产成人亚洲综合91| 精品久久久91| 一本色道久久88综合亚洲精品ⅰ| 2019中文字幕在线| 日韩亚洲在线观看| 日韩成人免费视频| 亚洲影视九九影院在线观看| 亚洲福利视频专区| 美女福利精品视频| 91精品久久久久久久| 综合欧美国产视频二区| 最近2019中文免费高清视频观看www99| 日韩资源在线观看| 精品视频久久久| 中文一区二区视频| 国产一区二区三区在线观看网站| 国产精品2018| 亚洲资源在线看| 国色天香2019中文字幕在线观看| 2023亚洲男人天堂| 日本精品一区二区三区在线| 日本欧美一二三区| 中文字幕国内精品| 欧美激情亚洲一区| 国产精品com| 久久久久久久成人| 久久影视免费观看| 成人av资源在线播放| 亚洲欧美日韩国产精品| 国产欧美va欧美va香蕉在| 精品女同一区二区三区在线播放| 亚洲精品色婷婷福利天堂| 91免费人成网站在线观看18| 91久久中文字幕| 高清一区二区三区日本久| 美女黄色丝袜一区| 岛国视频午夜一区免费在线观看| 亚洲男子天堂网| 亚洲欧美日韩国产成人| 欧美精品九九久久| 92福利视频午夜1000合集在线观看| 欧美成人精品h版在线观看| 精品久久久91| 亚洲精品一区二区网址| 欧美视频不卡中文| 精品久久久一区| 成人伊人精品色xxxx视频| 国产精品久久久久久久av电影| 国产成人精品电影| 2019日本中文字幕| 国内揄拍国内精品少妇国语| 亚洲色图13p| 91影院在线免费观看视频| 欧美午夜电影在线| 国产极品精品在线观看| 午夜伦理精品一区| 一区二区国产精品视频| 亚洲在线免费看| 欧美大片大片在线播放| 欧美激情第99页| 亚洲欧洲成视频免费观看| 91高潮在线观看| 亚洲在线一区二区| 亚洲人成亚洲人成在线观看| 国产精品久久久久999| 欧美成人在线影院| 美女精品视频一区| 亚洲第一免费网站| 日韩av在线电影网| 91亚洲精品一区| 成人欧美一区二区三区在线湿哒哒| 91sa在线看| 69av在线播放| 欧美精品电影免费在线观看| 久久久久久久网站| 一区二区国产精品视频| 久久人人爽人人爽爽久久| 精品久久久91| 91黑丝在线观看| 欧美激情综合色综合啪啪五月| 正在播放国产一区| 亚洲精品网址在线观看| 91精品国产99久久久久久| 久久99久国产精品黄毛片入口| 久久亚洲精品网站| 国产视频精品xxxx| 久久综合免费视频影院| 欧美专区日韩视频| 成人精品一区二区三区电影免费| 国产一区二区黄| 亚洲成人免费在线视频| 国产美女精彩久久| 最近2019年手机中文字幕| 亚洲激情免费观看| 亚洲黄色av女优在线观看| 神马久久久久久| 亚洲精品视频播放| 亚洲三级黄色在线观看| 国产精品流白浆视频| 91手机视频在线观看| 97视频免费在线观看| 日韩精品在线观| 国产手机视频精品| 欧美精品videos另类日本| 午夜精品久久久久久99热软件| 成人精品视频久久久久| 国产精品视频中文字幕91| 伊人av综合网| 亚洲成人精品av| 97精品欧美一区二区三区| 欧美怡春院一区二区三区| 国产精品一久久香蕉国产线看观看| www国产精品视频| 美女久久久久久久久久久| 777精品视频| 日韩成人av网址|