Page 6 of 9

10340 - WA

Posted: Sun Feb 05, 2006 4:55 pm
by abhi
here's my code........... i dunno y i get WA ?????

Code: Select all


CODE DELETED
 

Posted: Sun Feb 05, 2006 8:58 pm
by mamun
Input

Code: Select all

abhi anybodywilllikehim
Output

Code: Select all

Yes

Posted: Tue Feb 07, 2006 4:33 pm
by abhi
sorry i misunderstood the problem .but now i have changed the code and i
am getting TLE..........
plz help me .....

Code: Select all

CODE DELETD AFTER AC  :)
i was using the strlen() function exessively thats y TLE..... :lol:

10340

Posted: Wed Jul 05, 2006 8:48 am
by SHAHADAT
I'm bored of wrong answer....
I get wa many times.
whats the wrong here????


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<memory.h>
#define MAX 10000
char X[MAX],Y[MAX],string[MAX],store[MAX];
int i,j,m,n,c[MAX][MAX],b[MAX][MAX],k=0;
int LCSlength()
{
m=strlen(X);
n=strlen(Y);
for(i=1;i<=m;i++)
{
c[0]=0;
}
for(j=0;j<=m;j++)
{
c[0][j]=0;
}
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
if(X[i-1]==Y[j-1])
{
c[j]=c[i-1][j-1]+1;
b[j]=1;
}
else if(c[i-1][j]>=c[j-1])
{
c[j]=c[i-1][j];
b[j]=2;
}
else
{
c[j]=c[j-1];
b[j]=3;
}
}
}
return c[m][n];
}

void PrintLCS(int i,int j)
{
if(i==0 || j==0)return;
if(b[j]==1)
{
PrintLCS(i-1,j-1);
store[k]=X[i-1];

k++;
}
else if(b[i][j]==2)PrintLCS(i-1,j);
else PrintLCS(i,j-1);
}

int main()
{

char c,*p;
int l;
while(gets(string))
{
memset(store,NULL,sizeof(store));
k=0;
p=strtok(string," ");
strcpy(X,p);
p=strtok(NULL," ");
strcpy(Y,p);
LCSlength();
PrintLCS(m,n);
if(strcmp(X,store)==0)printf("Yes\n");
else printf("No\n");
}
}

Posted: Fri Jul 07, 2006 6:53 pm
by albet_januar
i don't understand with your solution, but i see a pointer variable..
i suggest to change this with common variable..

and don't make array to big..
i got ACC with array[1000000]

hope this will help u..
God Bless..

10340 PE

Posted: Fri Jul 21, 2006 7:33 pm
by Donotalo
i'm getting PE, why? my output code:

Code: Select all

cout << (j == s2 ? "YES" : "NO") << endl;
j and s2 are integers. Help please!

Posted: Sat Jul 22, 2006 1:40 pm
by jan_holmes
I think it should be :

Code: Select all

cout << (j == s2 ? "Yes" : "No") << endl; 
*use lowercase letters...

10340 WA

Posted: Fri Mar 23, 2007 2:18 am
by shumphreys
Hi, I am also getting wrong answer, I have read all the posts relating to this and increased my array size and tested with all forum suggested input data, my code gives the right results but still getting WA. Any ideas?

Code: Select all

<snipped>
thx

Posted: Fri Mar 23, 2007 11:30 am
by mamun
Try this input

Code: Select all

abc axbycz
abc xyz
You might get run-time error. Declare the char arrays as static or global.

10340 WA

Posted: Fri Mar 23, 2007 12:23 pm
by shumphreys
Hi, Thx for the response.
The test data you gave me passes OK. I am getting a WA rather than RE from the judge. I do not usually use C++ but I thought the arrays were global i.e. declared outside of main, or do I need to specify that in some way with a directive?
Thx
S

Posted: Fri Mar 23, 2007 12:37 pm
by mamun
For above input your code produces

Code: Select all

Yes
Yes
though the output should be

Code: Select all

Yes
No
Your arrays aren't global, you've declared them inside main().

10340 WA

Posted: Fri Mar 23, 2007 3:16 pm
by shumphreys
Hi Mamun,

Thx for the response - what was I thinking of? ..... Red-faced here and glad to be shown the error .... back to the drawing board on this one ... very grateful for your help ..
S

AC

Posted: Fri Mar 23, 2007 6:29 pm
by shumphreys
AC finally - thanks mamun for pointing me on the right path!

I got WA....= =

Posted: Wed Jul 18, 2007 4:59 pm
by Waddle
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
char s[100000], t[100000];
long int m, n, i, j, D=0;
while( scanf("%s %s",&s,&t) == 2 )
{
m = strlen(s);
n = strlen(t);

D = 0;


i = 0;
for(j=0;j<m;j++)
{
while(i < n)
{
if(s[j] == t[i])
{
s[j] = '*';
break;
}
else
i++;
}
}

for(j=0;j<m;j++)
{
if(s[j] != '*')
{
printf("No\n");
D = -1;
break;
}
}
if(D != -1)
printf("Yes\n");

}

return 0;
}

I can't find where I went wrong....

Can anyone give me some advice or new cases?

Posted: Tue Oct 30, 2007 3:05 pm
by alamgir kabir
At last accepted.

Code: Select all

//code removed
Thank's a lot helloneo