10340 - All in All

All about problems in Volume 103. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

abhi
Learning poster
Posts: 94
Joined: Fri Nov 25, 2005 7:29 pm

10340 - WA

here's my code........... i dunno y i get WA ?????

Code: Select all

``````
CODE DELETED
``````
Last edited by abhi on Tue Feb 07, 2006 4:59 pm, edited 1 time in total.

mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Contact:
Input

Code: Select all

``abhi anybodywilllikehim``
Output

Code: Select all

``Yes``

abhi
Learning poster
Posts: 94
Joined: Fri Nov 25, 2005 7:29 pm
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.....

New poster
Posts: 23
Joined: Thu Jun 22, 2006 8:55 am

10340

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");
}
}

albet_januar
New poster
Posts: 35
Joined: Wed Apr 12, 2006 6:03 pm
Location: jakarta, indonesia
Contact:
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..

Donotalo
Learning poster
Posts: 56
Joined: Sat Aug 20, 2005 11:05 am

10340 PE

i'm getting PE, why? my output code:

Code: Select all

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

jan_holmes
Experienced poster
Posts: 136
Joined: Fri Apr 15, 2005 3:47 pm
Location: Singapore
Contact:
I think it should be :

Code: Select all

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

shumphreys
New poster
Posts: 6
Joined: Wed Mar 21, 2007 7:24 pm

10340 WA

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
Last edited by shumphreys on Fri Mar 23, 2007 3:17 pm, edited 1 time in total.

mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Contact:
Try this input

Code: Select all

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

shumphreys
New poster
Posts: 6
Joined: Wed Mar 21, 2007 7:24 pm

10340 WA

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

mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Contact:
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().

shumphreys
New poster
Posts: 6
Joined: Wed Mar 21, 2007 7:24 pm

10340 WA

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

shumphreys
New poster
Posts: 6
Joined: Wed Mar 21, 2007 7:24 pm

AC

AC finally - thanks mamun for pointing me on the right path!

New poster
Posts: 22
Joined: Thu Jan 25, 2007 3:54 pm
Location: Taiwan
Contact:

I got WA....= =

#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?

alamgir kabir
New poster
Posts: 37
Joined: Wed Oct 03, 2007 10:42 am
At last accepted.

Code: Select all

``````//code removed
``````
Thank's a lot helloneo
Last edited by alamgir kabir on Wed Oct 31, 2007 2:38 pm, edited 2 times in total.