标签:scan amp return blog ret bsp strstr char ace
http://acm.xidian.edu.cn/problem.php?id=1140
KMP效率真心低,cstring中的strstr快多了。
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main() { int n; while(~scanf("%d",&n)) { int ans = 0; char a[50000],b[50000]; while(n--) { scanf("%s",a); strcat(b,a); char *p = b,*o; while(o = strstr(p,"wanshen")) { p = o+7; ans++; } strcpy(b,p); } printf("%d\n",ans); } return 0; }
标签:scan amp return blog ret bsp strstr char ace
原文地址:http://www.cnblogs.com/zhurb/p/6017881.html