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

Post by abhi » Sun Feb 05, 2006 4:55 pm

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
Location: Bangladesh
Contact:

Post by mamun » Sun Feb 05, 2006 8:58 pm

Input

Code: Select all

abhi anybodywilllikehim
Output

Code: Select all

Yes

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

Post by abhi » Tue Feb 07, 2006 4:33 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..... :lol:

SHAHADAT
New poster
Posts: 23
Joined: Thu Jun 22, 2006 8:55 am
Location: sust,bangladesh

10340

Post by SHAHADAT » Wed Jul 05, 2006 8:48 am

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:

Post by albet_januar » Fri Jul 07, 2006 6:53 pm

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..

User avatar
Donotalo
Learning poster
Posts: 56
Joined: Sat Aug 20, 2005 11:05 am
Location: Bangladesh

10340 PE

Post by Donotalo » Fri Jul 21, 2006 7:33 pm

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

Code: Select all

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

jan_holmes
Experienced poster
Posts: 136
Joined: Fri Apr 15, 2005 3:47 pm
Location: Singapore
Contact:

Post by jan_holmes » Sat Jul 22, 2006 1:40 pm

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

Post by shumphreys » Fri Mar 23, 2007 2:18 am

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
Location: Bangladesh
Contact:

Post by mamun » Fri Mar 23, 2007 11:30 am

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

Post by shumphreys » Fri Mar 23, 2007 12:23 pm

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
Location: Bangladesh
Contact:

Post by mamun » Fri Mar 23, 2007 12:37 pm

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

Post by shumphreys » Fri Mar 23, 2007 3:16 pm

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

Post by shumphreys » Fri Mar 23, 2007 6:29 pm

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

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

I got WA....= =

Post by Waddle » Wed Jul 18, 2007 4:59 pm

#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

Post by alamgir kabir » Tue Oct 30, 2007 3:05 pm

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.

Post Reply

Return to “Volume 103 (10300-10399)”