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

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo »

Try this case..

Code: Select all

a b
:-)

PS. Remove your code after AC..

DanielMarques
New poster
Posts: 5
Joined: Thu Jan 24, 2008 7:13 pm
Location: Rio de Janeiro

WA

Post by DanielMarques »

Getting WA in this code. I've already tried the cases posted here and they all worked.

Code: Select all

Got AC
Last edited by DanielMarques on Wed Feb 13, 2008 10:26 pm, edited 1 time in total.

sapnil
Experienced poster
Posts: 106
Joined: Thu Apr 26, 2007 2:40 pm
Location: CSE-SUST
Contact:

Post by sapnil »

Cheque this:

Code: Select all

Input:
aa ab
Output:
No
Thanks
Keep posting
Sapnil
"Dream Is The Key To Success"

@@@ Jony @@@

DanielMarques
New poster
Posts: 5
Joined: Thu Jan 24, 2008 7:13 pm
Location: Rio de Janeiro

Post by DanielMarques »

It worked! :D
Thanks sapnil

fR0D
New poster
Posts: 29
Joined: Mon Feb 11, 2008 5:59 am
Contact:

why is my programm giving WA

Post by fR0D »

here's my code..i cant understand y it gives WA plz help..

Code: Select all

#include<iostream>
using namespace std;
#include<string.h>

int main()
{
    char str1[1000000],str2[1000000];
    int l1,l2,i,j,FLAG=1;
    while (scanf("%s%s",str1,str2)!=EOF)
    {
          FLAG=1;
          l1=strlen(str1);
          l2=strlen(str2);
          for (i=0,j=0;i<l1 && j<l2 && l1<=l2;i++)
          {
              for (;j<l2;j++)
                   if (str1[i]==str2[j])     
                   {    
                      j++;
                      break;
                   }
          }                    
          if(i!=l1 || (l1==l2 && strcmp(str1,str2)!=0))
                   FLAG=0;
          if(FLAG==0)
                     printf("No\n");
          else
              printf("Yes\n");
    }
}

fR0D
New poster
Posts: 29
Joined: Mon Feb 11, 2008 5:59 am
Contact:

Post by fR0D »

what is the output in case of
input:

abc abc

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Yes.

fR0D
New poster
Posts: 29
Joined: Mon Feb 11, 2008 5:59 am
Contact:

Post by fR0D »

can u give some tricky cases or figur out why my program gives WA??

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Try the case.

Input:

Code: Select all

abcc abcdddd
Output:

Code: Select all

No
Hope it helps.

diegororiz
New poster
Posts: 1
Joined: Fri May 23, 2008 10:44 pm

10340 - WA

Post by diegororiz »

I've got a RE and i do'nt know why!
If anybody can help me!!

Code: Select all

Got acc
thks!
Last edited by diegororiz on Thu Jul 17, 2008 12:41 am, edited 1 time in total.

The_Madman
New poster
Posts: 12
Joined: Fri May 23, 2008 10:24 pm

Re:

Post by The_Madman »

asif_rahman0 wrote:Array size should be 1000000.
thanx bro....it really helped and now's been accepted. but here comes a question....how can one assume the length of these string type questions...some days ago...i was stuck by this same kind of prob..while the algo was ok..it needed to change the string length to 1000 so this time i thought 1000 is sufficient..but alas!

do you know anything regarding it?

theharshest
New poster
Posts: 20
Joined: Thu Jan 17, 2008 10:47 pm
Location: India

WA pls help

Post by theharshest »

I am getting WA for this code -- pls help :(

Code: Select all

#include<iostream>
#include<string>

using namespace std;

int main()
{

string s,t;

long i,j;

while(cin>>s>>t)
{
 i=0;
 j=0;
 while(1)
 {
  if(s[i]==t[j])
  {
  if(s[i-1]==t[j-1] || i==0 || j==0)
   {i++;
   j++;}
   else
   j++;
  }          
  else
   j++;
  
 //cout<<s[i]<<" "<<t[j]<<endl;
  if(i==(s.length()) || j==(t.length()))
  break;              
 }
 if(i==(s.length()))
 cout<<"Yes"<<endl;
 else
 cout<<"No"<<endl;
 
}    

}
"if u r goin thru hell, keep goin"

rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Re: 10340 - All in All

Post by rio »

Your code doesn't even pass the sample io.
Try to output it correctly, and you'll understand wheres your mistake is.

-----
Rio

fjfj
New poster
Posts: 1
Joined: Fri Nov 26, 2010 11:48 pm

Re: 10340 - All in All

Post by fjfj »

why WA???
please help!! :cry: :cry:

Code: Select all

#include <stdio.h>
#include <string.h>
char *s1,*s2,s[2000010];
int main()
{
	char flag,i,j,l1,l2,k;
	while (gets(s)!=NULL)
	{
		s1=strtok(s," ");
		s2=strtok(NULL," ");
		l1=strlen(s1);
		l2=strlen(s2);
		if (l1>l2)
		{
			printf("No\n");
			continue;
		}
		else if (strstr(s1,s2)!=NULL)
		{
			printf("Yes\n");
			continue;
		}
		else
		{
			k=0;
			for (i=0;s1[i]!='\0';i++)
			{
				flag=0;
				for (j=k;s2[j]!='\0';j++)
				{
					if (s1[i]==s2[j])
					{
						flag=1;
						s2[j]=' ';
						k=j;
						break;
					}
				}
				if (flag==0)
					break;
			}
			if (flag==0)
				printf("No\n");
			else if (flag==1)
				printf("Yes\n");
		}
	}
	return 0;
}

sith
Learning poster
Posts: 72
Joined: Sat May 19, 2012 7:46 pm

Re: 10340 - All in All

Post by sith »

Hello!
I've got WA but I believe that my solution is correct. All cases from this thread, proof it.

Here is my code

Code: Select all

AC
Helppppppp!
Last edited by sith on Wed Jun 13, 2012 11:43 pm, edited 1 time in total.

Post Reply

Return to “Volume 103 (10300-10399)”