比赛 |
防止颓废的小练习v0.15 |
评测结果 |
AAAAAAAAAA |
题目名称 |
统计单词数 |
最终得分 |
100 |
用户昵称 |
Rapiz |
运行时间 |
0.035 s |
代码语言 |
C++ |
内存使用 |
6.97 MiB |
提交时间 |
2016-10-17 20:51:34 |
显示代码纯文本
- #include<cstdio>
- #include<cstring>
- #include<cctype>
- #define file(x) "stat."#x
- const int LEN=1e6+10;
- char a[LEN],b[LEN],buf[LEN];
- int l1,l2,nxt[LEN],pos,cnt,tol,ans;
- bool match(){
- if(l1!=l2) return false;
- for(int i=1;i<=l2;i++) if(a[i]!=tolower(b[i])) return false;
- return true;
- }
- bool read(){
- l2=0;
- pos++;
- while(buf[pos]&&isspace(buf[pos])) pos++;
- b[++l2]=buf[pos];
- while(isgraph(buf[pos+1])) b[++l2]=buf[++pos];
- return pos<=tol;
- }
- int main(){
- freopen(file(in),"r",stdin);
- freopen(file(out),"w",stdout);
- gets(a+1);
- gets(buf+1);
- l1=strlen(a+1);
- tol=strlen(buf+1);
- for(int i=1;i<=l1;i++) a[i]=tolower(a[i]);
- while(read()) {
- if(match()){
- if(!cnt) ans=pos-l2;
- cnt++;
- }
- }
- if(cnt) printf("%d %d",cnt,ans);
- else printf("-1");
- }