|
|
back to boardWrong Answer For Test 19 I Got a Wrong Answer For Test 19.. Can Anyone tell what the corresponding input .. if known.. #include<stdio.h> #include<string.h> int main() { int **a,i,j; int answer[2],len,n; char str[1001],revstr[1001]; scanf("%s",&str); n=strlen(str); a=(int**)malloc(sizeof(int**)*n); for(i=0;i<n;i++) a[i]=(int*)malloc(sizeof(int)*n); for(i=0;i<n;i++) for(j=0;j<n;j++) a[i][j]=0; strcpy(revstr,str); for(i=0;i<strlen(str);i++) revstr[i]=str[strlen(str)-i-1]; revstr[i]='\0'; answer[0]=0; answer[1]=0; len=0; for(i=0;i<strlen(str);i++) { for(j=0;j<strlen(revstr);j++) { if(str[i]!=revstr[j]) a[i][j]=0; else { if(i==0||j==0) a[i][j]=1; else a[i][j]=1+a[i-1][j-1]; if(a[i][j]>len) { len=a[i][j]; answer[0]=i; answer[1]=j; } } } } for(i=answer[0]-len+1;i<=answer[0];i++) printf("%c",str[i]); return 0; } Edited by author 23.11.2007 01:20 Re: Wrong Answer For Test 19 Try this: 'qwerSOMETEXTrewq', goodluck!;-) Re: Wrong Answer For Test 19 Posted by al_prix 15 Jul 2015 15:08 And what is to be an answer? Re: Wrong Answer For Test 19 Posted by luckyq 5 Sep 2015 18:49 The right answer is ETE.I use suffix_array to solve this problem.And I got ac . Re: Wrong Answer For Test 19 please help me I also use suffix array, I still wa on #7 |
|
|