468 - Key to Success
Moderator: Board moderators
468 - Key to Success
Could someone give some critical case of input?
WA
Hello,
First I got RTE, fixed it, now I got WA
, but this time I could not fix it.
Can anyone enlighten me?
Thanks in advance.
Here's my code:
[c]Code Removed[/c]
First I got RTE, fixed it, now I got WA

Can anyone enlighten me?

Thanks in advance.
Here's my code:
[c]Code Removed[/c]
One thing I noticed is that you have:
I assume 26 is there because there are 26 letters. But this problem says that capital are distinct from lowercase, so this should be 52
Code: Select all
for(i=0;i<26;i++)
Last edited by Ryan Pai on Fri Jul 08, 2005 5:21 pm, edited 1 time in total.
I'm always willing to help, if you do the same.
- Ali Arman Tamal
- Learning poster
- Posts: 76
- Joined: Sat Jan 15, 2005 5:04 pm
- Location: Dhaka
- Contact:
Hello !
yiuyuho wrote:

yiuyuho wrote:
Problem description says:This is weird, I submitted 2 versions of code, one treating uppercase and lowercase as different letters, and one treating upper and lower as same letter, but output them according to their case. Both get PE
Note: You have to print a newline even after the last test case (though it is not said).The outputs of two consecutive cases will be separated by a blank line.
468 - WA!
what 's wrong?
I dont know...
Do you?
I dont know...
Do you?
Code: Select all
/*
468 - key to success
submission 1 runtime error 2 runtime error 3 WA 4 WA
coded at 5:08pm on 6th oct 05
comment: did i make it complex? i dont think so!
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define MAX 10000
int main() {
char not_encoded[MAX+1],encoded[MAX+1];
int i,j,len;
int tcases;
char flag=0;
struct{
char ch;
int occ;
}lower[52],higher[52],temp;
scanf("%d",&tcases);
for(;tcases>0;tcases--) {
scanf("%s",not_encoded);
scanf("%s",encoded);
len=strlen(not_encoded);
if(flag) printf("\n");
for(i=0;i<26;i++) {
lower[i].ch=i+'a';
higher[i].ch=i+'a';
higher[i].occ=0;
lower[i].occ=0;
}
for(i=26;i<52;i++) {
lower[i].ch=i+'A'-26;
higher[i].ch=i+'A'-26;
higher[i].occ=0;
lower[i].occ=0;
}
for(i=0;i<len;i++) {
if(not_encoded[i]>='a' && not_encoded[i]<='z')
lower[not_encoded[i]-'a'].occ++;
else if(isalpha(not_encoded[i]))
lower[not_encoded[i]-'A'+26].occ++;
}
for(i=0;i<51;i++)
for(j=i+1;j<52;j++)
if(lower[i].occ<lower[j].occ) {
temp=lower[i];
lower[i]=lower[j];
lower[j]=temp;
}
len=strlen(encoded);
for(i=0;i<len;i++) {
if(encoded[i]>='a' && encoded[i]<='z')
higher[encoded[i]-'a'].occ++;
else if(isalpha(not_encoded[i]))
higher[encoded[i]-'A'+26].occ++;
}
for(i=0;i<51;i++)
for(j=i+1;j<52;j++)
if(higher[i].occ<higher[j].occ) {
temp=higher[i];
higher[i]=higher[j];
higher[j]=temp;
}
for(i=0;;i++) {
if(higher[i].occ==0) break;
for(j=0;j<len;j++) {
if(higher[i].ch==encoded[j])
encoded[j]=lower[i].ch;
}
}
puts(encoded);
flag=1;
}
return 0;
}
Last edited by smilitude on Mon Nov 28, 2005 11:39 am, edited 1 time in total.
fahim
#include <smile.h>
#include <smile.h>
-
- Experienced poster
- Posts: 161
- Joined: Tue Oct 25, 2005 8:38 pm
- Location: buet, dhaka, bangladesh
The input begins with a single positive integer on a line by itself indicating the number of the cases following. say the integer is 3. then there must be 3 sets of inputs.
Every sets must not be same, i write the same inputs only for example.
then the output must be:
i write my code as:
Code: Select all
3
<- empty line
abacxbacac
qqqqqrrrrssstt
<- empty line
abacxbacac
qqqqqrrrrssstt
<- empty line
abacxbacac
qqqqqrrrrssstt
EOF
then the output must be:
Code: Select all
aaaaaccccbbbxx
<- empty line
aaaaaccccbbbxx
<- empty line
aaaaaccccbbbxx
Code: Select all
scanf("%d", &test);
for(count = 0; count < test; ++count)
{
scanf(" %[^\n]", s);
scanf(" %[^\n]", p);
.........
.........
}
ishtiak zaman
----------------
the world is nothing but a good program, and we are all some instances of the program
----------------
the world is nothing but a good program, and we are all some instances of the program