用G++过了,c++无限WA



就是一水,就是求输入的字符串中是否有一个是其他字符串的子串;
注意这种数据。。。
0000
010
01
9
字符串的长度从大到小;
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
char qq[20005];
struct node{
int q[2];
int w;
node()
{
w=0;
memset(q,-1,sizeof(q));
}
}s[10000];
int sz=1;
int show(char *qq)
{
int x=0,v=0;
int len=strlen(qq);
for(int i=0;i<len;i++)
{
int y=qq[i]-'0';
if(s[x].q[y]==-1)
s[x].q[y]=sz++;
if(s[x].w==1)
v=1;
x=s[x].q[y];
}
if(s[x].w==1)
v=1;
s[x].w=1;
if(s[x].q[0]!=-1||s[x].q[1]!=-1)
v=1;
return v;
}
void yy()
{
for(int i=0;i<10000;i++)
{s[i].w=0;
memset(s[i].q,-1,sizeof(s[i].q));
}
}
int main()
{
int t=0;
while(gets(qq)!=NULL)
{
int u;
if(qq[0]=='9')
{
t++;
if(u==0)
printf("Set %d is immediately decodable\n",t);
else
printf("Set %d is not immediately decodable\n",t);
u=0;
yy();
sz=1;
continue;
}
if(u==1)
continue;
u=show(qq);
}
return 0;
}
hdu 1305 Immediate Decodability,布布扣,bubuko.com
hdu 1305 Immediate Decodability
原文地址:http://blog.csdn.net/asuxiexie/article/details/38013025