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

Post Reply
User avatar
Sedefcho
A great helper
Posts: 374
Joined: Sun Jan 16, 2005 10:18 pm
Location: Bulgaria

Post by Sedefcho » Fri Feb 25, 2005 1:25 am

Could you please give me some more details about your
[len (X) * len (Y)] brute force solution ?

Is O [len (X) * len (Y)] your time complexity ?

59557RC
New poster
Posts: 26
Joined: Sun Mar 20, 2005 9:28 pm
Location: bangladesh
Contact:

10340-pls help

Post by 59557RC » Sun Apr 24, 2005 12:35 pm

why i got WA all time for10340:

#include<stdio.h>
#include<string.h>

int main(void)
{

char s[500],t[500];
int i,j,k,m;
fgets(s,501,stdin);
fgets(t,501,stdin);
while(feof(stdin)==0){

k=1;
m=0;
for(i=0;i<strlen(s);i++){
if(k==1){
for(j=m;j<strlen(t);j++){
if(s==t[j]) {m=j;k=1;break;}
else if(s!=t[j]) k=0;} }

else if(k==0) break; }

if(k==1) printf("Yes\n");
else printf ("No\n");
fgets(s,501,stdin);
fgets(t,501,stdin);

}
return 0;
}
aaa

User avatar
J&Jewel
New poster
Posts: 50
Joined: Thu Jul 31, 2003 10:43 am
Location: Daffodil University,Dhaka,Bangladesh
Contact:

Post by J&Jewel » Wed Apr 27, 2005 1:15 pm

Hello dear
U should take a string.. and then by *parseing* the input string and u
get the 1st string s and then t....
then find the length of them.

Do not use the strlen function in the loop...it may be some time causes for
compile error...

if u need more help continue....posting.
I hate Wrong Answer!

dootzky
New poster
Posts: 36
Joined: Tue Apr 12, 2005 12:20 am
Location: belgrade, serbia (ex yugoslavia)
Contact:

haha! omg omg omg!

Post by dootzky » Sat May 07, 2005 2:37 pm

this test case was so cool!

i was so naive to skip one letter in my search algo!!

haha! fuuuuunny! :lol: :P :D

thx Jewel of DIU, helped a lot. :wink:

best regards,
dootzky

User avatar
jaracz
Learning poster
Posts: 79
Joined: Sun Sep 05, 2004 3:54 pm
Location: Poland

10340

Post by jaracz » Fri May 27, 2005 11:38 am

Anyone see the reason of gettin' WA?

Code: Select all

sorry;)
Regards
Last edited by jaracz on Tue May 31, 2005 10:21 pm, edited 2 times in total.
keep it real!

WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR » Mon May 30, 2005 10:01 am

Try with a greater value for max.

My program defined max = 1000001

User avatar
jaracz
Learning poster
Posts: 79
Joined: Sun Sep 05, 2004 3:54 pm
Location: Poland

Post by jaracz » Mon May 30, 2005 11:10 pm

Actually, the size doesn't matter...
I can enlarge strings even to 500.000 but results are same
keep it real!

Mohammad Mahmudur Rahman
Experienced poster
Posts: 154
Joined: Sat Apr 17, 2004 9:34 am
Location: EEE, BUET

Post by Mohammad Mahmudur Rahman » Mon May 30, 2005 11:31 pm

As I see, you are swapping the strings when the first string is smaller then the second one which should not be the case. For example, your program will print 'YES' to the input -

Code: Select all

vivaVittorioEmanueleReDiItalia VERDI 
but here, the first string is not a subsequence of the second one & hence, it should output 'NO'. Hope it helps. :)
You should never take more than you give in the circle of life.

User avatar
jaracz
Learning poster
Posts: 79
Joined: Sun Sep 05, 2004 3:54 pm
Location: Poland

Post by jaracz » Tue May 31, 2005 10:20 pm

yeah man!!

You helped me so much!!
ACed now && gr8 thx!!
Last edited by jaracz on Tue May 31, 2005 10:37 pm, edited 1 time in total.
keep it real!

Mohammad Mahmudur Rahman
Experienced poster
Posts: 154
Joined: Sat Apr 17, 2004 9:34 am
Location: EEE, BUET

Post by Mohammad Mahmudur Rahman » Tue May 31, 2005 10:32 pm

Nice to know that you've got AC :D
You should never take more than you give in the circle of life.

asif_rahman0
Experienced poster
Posts: 209
Joined: Sun Jan 16, 2005 6:22 pm

Post by asif_rahman0 » Thu Jun 23, 2005 6:46 pm

Array size should be 1000000.

Salman
New poster
Posts: 25
Joined: Thu Jun 26, 2003 9:45 am

How to solve LCS or Adhoc

Post by Salman » Sat Oct 08, 2005 10:54 am

Can this problem solve able using LCS or it is just a adhoc problem?

User avatar
smilitude
Experienced poster
Posts: 137
Joined: Fri Jul 01, 2005 12:21 am

Post by smilitude » Wed Oct 12, 2005 1:50 am

Ya , i tried to do it by lcs! it cost me dozen of runtime error and two memory limit exceeded! then i do the adhoc, and it was so simple to manage an AC!

Sometime we people make the simple things really complex! :lol: [/quote]
fahim
#include <smile.h>

athlon19831
New poster
Posts: 20
Joined: Thu Jan 19, 2006 2:32 pm

10340 Runtime Error (help)

Post by athlon19831 » Tue Jan 24, 2006 7:31 am

why i got Runtime Error? who can help me?
my code:
#include "iostream.h"
#include "string.h"
char s[1000],t[1000];
int main(int argc, char* argv[])
{
int i,j;
int k;
while(cin>>s>>t)
{
k=0;
i=0;
j=0;
for(;i<strlen(s),j<strlen(t);)
{
if(s==t[j])
{
k++;
i++;
j++;
}
else
{
j++;
}
}
if(k==strlen(s))
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
return 0;
}

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

Post by mamun » Tue Jan 24, 2006 11:24 am

Probably input string length is much larger than 1000.
Use Code tagging for posting your code. Look at your code. Where that smily face came from, you think?

Post Reply

Return to “Volume 103 (10300-10399)”