468 - Key to Success
Moderator: Board moderators
-
- Experienced poster
- Posts: 122
- Joined: Sun Nov 13, 2005 10:25 am
- Location: Taiwan
468 want some inputs and outputs
Can sopmeone give me some I/O on problem 468?
Thanks very much.
Thanks very much.
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...
Thanx in advance,
Yandry.
Code: Select all
Cut after AC
Yandry.
468
This is my 1st post....
can anyone give me some input/output for 468.....
pleaz cheak my input/output:
input:
output:
thanks

can anyone give me some input/output for 468.....
pleaz cheak my input/output:
input:
Code: Select all
2
aabbac
pqrppqrpq
aabbac
pqrppqrpq
Code: Select all
abcaabcab
----------------------<newline
abcaabcab
form kisui na ... class tai asol....
iF U hv d class u get the form....
iF U hv d class u get the form....
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
HomePage
-
- New poster
- Posts: 27
- Joined: Mon Nov 27, 2006 4:44 am
- Location: Indonesia
Last edited by razor_blue on Tue Dec 05, 2006 5:52 am, edited 1 time in total.
Check the following sample...
Input:
Output:
Hope it helps.
Input:
Code: Select all
1
abacxbacacAAAAAAAAAA
qqqqqrrrrsssttwwwwwwwwwwwww
Code: Select all
aaaaaccccbbbxxAAAAAAAAAAAAA
Ami ekhono shopno dekhi...
HomePage
HomePage
-
- New poster
- Posts: 27
- Joined: Mon Nov 27, 2006 4:44 am
- Location: Indonesia
468.......WA
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");
}
}
#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.......]
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.
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]
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
output for all the cases given on board about this topic.Thanks in advance.
Code: Select all
-
- Learning poster
- Posts: 56
- Joined: Tue Jun 13, 2006 5:18 pm
- Location: (CSE, SUST) Sylhet, Bangladesh
- Contact:
My Accepted code give the output for your input.
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.
Code: Select all
rrrrrrrrrrrrtttttttttttttttttttttttttttttteeeeeewwwwq
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.
Re: 468 - WA!
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/
http://akanoi.webs.com/
-
- New poster
- Posts: 9
- Joined: Wed Jul 09, 2008 10:12 pm
468 : How input will be taken
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.
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.
Re: 468 - WA!
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.
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.
-
- New poster
- Posts: 16
- Joined: Fri Nov 15, 2013 9:33 pm
Re: 468 - Key to Success
Getting WA. Please help...
This one is getting WA too.. !!!


Code: Select all
Removed after AC
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.