468 - Key to Success

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

Moderator: Board moderators

Wei-Ming Chen
Experienced poster
Posts: 122
Joined: Sun Nov 13, 2005 10:25 am
Location: Taiwan

468 want some inputs and outputs

Post by Wei-Ming Chen » Sat Feb 04, 2006 10:31 am

Can sopmeone give me some I/O on problem 468?
Thanks very much.

neno_uci
Experienced poster
Posts: 104
Joined: Sat Jan 17, 2004 12:26 pm
Location: Cuba

Post by neno_uci » Fri May 19, 2006 12:04 am

Can somebody give me some I/O that does not work with my code..., I guess I am confused because I can't find my mistake, I am always getting WA...

Code: Select all

Cut after AC
Thanx in advance,

Yandry.

joy
New poster
Posts: 48
Joined: Wed Oct 18, 2006 1:00 pm
Location: Dhaka, Bangladesh
Contact:

468

Post by joy » Tue Oct 31, 2006 7:12 am

This is my 1st post.... :lol:

can anyone give me some input/output for 468.....

pleaz cheak my input/output:

input:

Code: Select all

2

aabbac
pqrppqrpq

aabbac
pqrppqrpq
output:

Code: Select all

abcaabcab
----------------------<newline
abcaabcab
thanks
form kisui na ... class tai asol....
iF U hv d class u get the form....

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

Post by Jan » Tue Oct 31, 2006 8:11 am

Your I/O set is correct. Dont open a new thread if there is one already. If there is no thread then open a new one.
Ami ekhono shopno dekhi...
HomePage

razor_blue
New poster
Posts: 27
Joined: Mon Nov 27, 2006 4:44 am
Location: Indonesia

Post by razor_blue » Mon Dec 04, 2006 10:31 am

Someone help me please,
I don't know why my code is WA...

Code: Select all

/* Removed after PE */
Last edited by razor_blue on Tue Dec 05, 2006 5:52 am, edited 1 time in total.

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

Post by Jan » Mon Dec 04, 2006 12:25 pm

Check the following sample...

Input:

Code: Select all

1

abacxbacacAAAAAAAAAA
qqqqqrrrrsssttwwwwwwwwwwwww
Output:

Code: Select all

aaaaaccccbbbxxAAAAAAAAAAAAA
Hope it helps.
Ami ekhono shopno dekhi...
HomePage

razor_blue
New poster
Posts: 27
Joined: Mon Nov 27, 2006 4:44 am
Location: Indonesia

Post by razor_blue » Tue Dec 05, 2006 5:54 am

Thank you Jan, I've fixed my code and got PE.

shaqira
New poster
Posts: 5
Joined: Tue Dec 05, 2006 10:16 am
Location: dhaka,bangladesh
Contact:

468.......WA

Post by shaqira » Tue Dec 05, 2006 10:35 am

my code is showin WA though it seams to me that it is givin the correct output, plz anyone help me with this........

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

char s1[40000][1000];
char s2[40000][1000];

struct N1
{
int f1;
char c1;

}line1[125];



struct N2
{
int f2;
char c2;

}line2[125];



bool cmp1(const N1 &a, const N1 &b)
{
if(a.f1!=b.f1)
if(a.f1>b.f1)
return true;
if(a.f1==b.f1)
if(a.c1<b.c1)
return true;
return false;
}

bool cmp2(const N2 &a, const N2 &b)
{
if(a.f2!=b.f2)
if(a.f2>b.f2)
return true;
if(a.f2==b.f2)
if(a.c2<b.c2)
return true;
return false;
}

void restore()
{
int i;
for(i=0;i<=122;i++)
{
line1.c1=i;
line1.f1=0;

line2.c2=i;
line2.f2=0;
}
}

void main()
{
int test,i,t,r,len1,len2;
scanf("%d",&test);

for(t=1;t<=test; t++)
{
scanf("%s",s1[t]);

if(strlen(s1[t])==0)
continue;

scanf("%s",s2[t]);

if(strlen(s2[t])==0)
continue;
}

for(t=1;t<=test;t++)
{
restore();
len1=strlen(s1[t]);

for(r=0;r<len1;r++)
{
if(s1[t][r]>='A' && s1[t][r]<='Z')
line1[s1[t][r]].f1++;
else if(s1[t][r]>='a' && s1[t][r]<='z')
line1[s1[t][r]].f1++;

}

len2=strlen(s2[t]);
for(r=0;r<len2;r++)
{
if(s2[t][r]>='A' && s2[t][r]<='Z')
line2[s2[t][r]].f2++;

else if(s2[t][r]>='a' && s2[t][r]<='z')
line2[ s2[t][r] ].f2++;

}
sort(line1,line1+122,cmp1);
sort(line2,line2+122,cmp2);
for(i=0;i<len2;i++)
{
for(r=0;r<=122;r++)

if(s2[t]==line2[r].c2)

printf( "%c",line1[r].c1 );

}

printf("\n");

}
}
[ only a beginner.......]

Anindya
New poster
Posts: 28
Joined: Sun Feb 04, 2007 4:34 am
Location: EEE,BUET,DHAKA

Post by Anindya » Wed Feb 21, 2007 8:56 am

What's wrong with my code? Somebody please check.I have two different
frequency arrays,then substituted max of line2 by max of line1,then i made this freq 0 & so on.

Code: Select all

removed after ac.
the case my code failed:
1

qwerwererrtttttttttttttttttttttttttttttttttttttttttttttttttttt
yyyyyyyyyyyyZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZwwwwwweeeea
Help me to find some bug or give some sample i/o.My code gives correct
output for all the cases given on board about this topic.Thanks in advance.[quote][/quote]

Mushfiqur Rahman
Learning poster
Posts: 56
Joined: Tue Jun 13, 2006 5:18 pm
Location: (CSE, SUST) Sylhet, Bangladesh
Contact:

Post by Mushfiqur Rahman » Wed Apr 18, 2007 3:47 pm

My Accepted code give the output for your input.

Code: Select all

rrrrrrrrrrrrtttttttttttttttttttttttttttttteeeeeewwwwq
I think the statement of this problem is very poor, because
they should clear what would be largest string size of the input. I got 3 times RE( signal 11 ) for the size of the input string. If anybody see the statistics of the problem than he will observe that the total AC runs is almost equal to total RE runs.

User avatar
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Post by sohel » Wed Apr 18, 2007 4:17 pm

This is an issue with some of the older problems - where the range of input isn't mentioned.
I usually use an array size of 10000 when range isn't explicitly stated.

However, there is a problem where the input size is 1000000 (cant remember the problem number) and still the range isn't mentioned

abid_iut
Learning poster
Posts: 82
Joined: Wed Jul 16, 2008 7:34 am

Re: 468 - WA!

Post by abid_iut » Sat Sep 06, 2008 5:40 pm

getting WA pls help!!!!

Code: Select all


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

int main()
{
	char a[10000],b[10000],c[10000],x,temp1;
	long n,i,j=0,k,l1,l2,count=0,q=0,k1=0,d[10000],temp,d1[10000],num[10000],p,min,k2=0,t;
	//freopen("468.txt","r",stdin);
	scanf("%ld",&n);
	for(k=0;k<n;k++){
		scanf("%s",a);
		scanf("%s",b);
	
	l1=strlen(a);
	l2=strlen(b);
	
	while(j<l1){
		count=0;
		x=a[j];
		if(x!='*'){c[q]=x;q++;}
		for(i=0;i<l1;i++){
			if(x==a[i] && a[i]!='*')count++;
			if(x==a[i])a[i]='*';
		}
		j++;
		if(count==0)continue;
		d[k1]=count;k1++;
	}

	for(i=0;i<k1;i++){
		for(j=i+1;j<k1;j++){
			if(d[i]<d[j]){
				temp=d[i];
				d[i]=d[j];
				d[j]=temp;

				temp1=c[i];
				c[i]=c[j];
				c[j]=temp1;
			}
		}
	}

	k1=0;
	while(j<l2){
		count=0;
		x=b[j];
		for(i=0;i<l2;i++){
			if(x==b[i] && b[i]!='*')count++;
			if(x==b[i])b[i]='*';
		}
		j++;
		if(count==0)continue;
		d1[k1]=count;k1++;
	}

	min=32000;
	for(i=0;i<k1;i++){
		if(d1[i]<min){
			min=d1[i];
			num[i]=min;
		}
	}

	p=0;
	for(i=0;i<k1;i++){
		k2=num[i];
		for(t=0;t<k2;t++)printf("%c",c[p]);
		p++;
	}
	printf("\n\n");
	}
	return 0;
}

i love to wait... wait for better... and better will come...
http://akanoi.webs.com/

tanvir_cse
New poster
Posts: 9
Joined: Wed Jul 09, 2008 10:12 pm

468 : How input will be taken

Post by tanvir_cse » Sat Nov 22, 2008 7:58 pm

hi Jan,
u told about printing an extra line after the last case.Here is my code. Getting WA again and again.
pls send me the code of taking input and printing output....

#include<stdio.h>
#include<math.h>
#include<string.h>
#define M 9000

int a1[M], a2[M] , p1[M] , p2[M] ;

int main(void)
{
char ch, change,cat,temp;
char s1[M],s2[M],str1[M],str2[M],c[M],final[M] , hash1[M] , hash2[M];
int i,j,k,m,n,p,testcase,x,len1,len2,total,flag=0;

scanf("%d",&testcase);
for( ;testcase>0 ; testcase--)
{
if(flag)
printf("\n");

scanf("%s",s1);
//scanf("%c",&ch);
scanf("%s",s2);
//scanf("%c",&ch);

strcpy(str1,s1);
strcpy(str2,s2);
len1=strlen(str1);
len2=strlen(str2);


for(i=0; s1; i++)
{
if(s1>=97 && s1<=123)
a1[s1]+=1;
else if(s1>=65 && s1<=91)
a1[s1]+=1;
}

for(i=0; s2; i++)
{
if(s2>=97 && s2<=123)
a2[s2[i]]+=1;
else if(s2[i]>=65 && s2[i]<=91)
a2[s2[i]]+=1;
}


for(i=0;i<len1;i++)
{
for(j=i+1;j<len1;j++)
{
if(str1[i]>str1[j])
{
temp=str1[i];
str1[i]=str1[j];
str1[j]=temp;
}
}
}
// puts(str1);

for(i=0;i<len2;i++)
{
for(j=i+1;j<len2;j++)
{
if(str2[i]>str2[j])
{
temp=str2[i];
str2[i]=str2[j];
str2[j]=temp;
}
}
}
//puts(str2);

m=j=0;
while(str1[m])
{
c[j]=str1[m];
for(i=m; str1[i]==c[j]; i++,m++);

if(c[j]>=97 && c[j]<=123)
{
x=a1[c[j]];
p1[j]=x;
}
else if(c[j]>=65 && c[j]<=91)
{
x=a1[c[j]];
p1[j]=x;
}

j++;
}
total=j;
for(i=0; i<total ; i++)
{
hash1[p1[i]]=c[i];
}
for(i=0;i<total;i++)
{
for(j=i+1;j<total;j++)
{
if(p1[i]<p1[j])
{
x=p1[i];
p1[i]=p1[j];
p1[j]=x;
}
}
}




m=j=0;
while(str2[m])
{
c[j]=str2[m];
for(i=m; str2[i]==c[j]; i++,m++);

if(c[j]>=97 && c[j]<=123)
{
x=a2[c[j]];
p2[j]=x;
}
else if(c[j]>=65 && c[j]<=91)
{
x=a2[c[j]];
p2[j]=x;
}

j++;
}
total=j;
for(i=0; i<total ; i++)
{
hash2[p2[i]]=c[i];
}
for(i=0;i<total;i++)
{
for(j=i+1;j<total;j++)
{
if(p2[i]<p2[j])
{
x=p2[i];
p2[i]=p2[j];
p2[j]=x;
}
}
}



for(i=0; i<total; i++)
{
ch=hash2[p2[i]];
change=hash1[p1[i]];
//cat=ch-change;
for(j=0; s2[j]; j++)
{
if(s2[j]==ch)
final[j]=change;

}
}
final[strlen(s2)]='\0';
puts(final);
flag=1;



}

printf("\n");

}

Pls answer me as soon as possible.I have also got WA some problems of this type.

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

Re: 468 - WA!

Post by Sedefcho » Mon Mar 02, 2009 11:41 pm

To abid_iut: I don't know if you already solved this problem.

But here is a small remark: the online judge wants a single \n after
the last test case output and two \n\n after each of the previous test cases.
If not printed this way - the judge says WA, if yes - the judge says ACC.

sabbir_alam_ufo
New poster
Posts: 16
Joined: Fri Nov 15, 2013 9:33 pm

Re: 468 - Key to Success

Post by sabbir_alam_ufo » Sat Jan 03, 2015 9:59 pm

Getting WA. Please help... :( :(

Code: Select all

Removed after AC
This one is getting WA too.. !!!

Code: Select all

Removed after AC
Last edited by sabbir_alam_ufo on Thu Jan 08, 2015 11:38 am, edited 1 time in total.

Post Reply

Return to “Volume 4 (400-499)”