Page 1 of 3

468 - Key to Success

Posted: Sat Jul 10, 2004 10:40 am
by htl
Could someone give some critical case of input?

Posted: Sat Jul 10, 2004 6:30 pm
by htl
I set the buffer to 3000 characters and get WA. I get PE after setting the buffer to 6000 characters. Than's strange. Now I don't know how to fix the PE.

WA

Posted: Sat Aug 28, 2004 6:02 pm
by Guest
Hello,
First I got RTE, fixed it, now I got WA :( , but this time I could not fix it.
Can anyone enlighten me? :cry:
Thanks in advance.

Here's my code:
[c]Code Removed[/c]

Posted: Sat Aug 28, 2004 8:54 pm
by Ryan Pai
One thing I noticed is that you have:

Code: Select all

for(i=0;i<26;i++)
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

Posted: Sat Aug 28, 2004 9:13 pm
by Ryan Pai
This is where I double posted and looked goofy.

AC

Posted: Sun Aug 29, 2004 7:43 am
by Guest
Hello Ryan,
Thank you for pointing out my mistake. It was a silly one. :wink: I forgot to change that 26 to 256 after noticing that the code should be case sensitive. Now I've got AC :D
Regards,

Posted: Tue Feb 08, 2005 6:52 pm
by abhijit
i get an ouput-limit-exceeded on this.
isn't it always the case for each input set, the output line is as long as the 2nd line in the input set ?

Posted: Sat Feb 12, 2005 1:52 am
by yiuyuho
yes, that is the case, if you still care, :lol:

Posted: Sat Feb 12, 2005 3:14 am
by yiuyuho
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 :o

So which way is intened by the problem setter?

Posted: Tue Feb 15, 2005 5:13 am
by Ali Arman Tamal
Hello ! :)


yiuyuho wrote:
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
Problem description says:
The outputs of two consecutive cases will be separated by a blank line.
Note: You have to print a newline even after the last test case (though it is not said).

468 - WA!

Posted: Sat Oct 08, 2005 1:54 am
by smilitude
what 's wrong?
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;
}
		
	

Posted: Thu Nov 03, 2005 10:48 am
by ayon
I am not sure about the line !!!
=> lower.ch=i+'A-26';

what is meant by 'A-26' ?

moreover this is a multiple input problem. you have to count how many testcases...

Posted: Sun Nov 27, 2005 8:21 pm
by smilitude
Oh, thanks a lot,
thats a good bug! [ i mean thats a serious bug! :roll: you know, bug cannot be good!]

thanks...
but whats wrong with multiple input output ...?
can you give me hint??

Posted: Mon Nov 28, 2005 9:03 am
by ayon
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.

Code: Select all

3
                    <- empty line
abacxbacac
qqqqqrrrrssstt
                    <- empty line
abacxbacac
qqqqqrrrrssstt
                    <- empty line
abacxbacac
qqqqqrrrrssstt
EOF
Every sets must not be same, i write the same inputs only for example.

then the output must be:

Code: Select all

aaaaaccccbbbxx
                          <- empty line
aaaaaccccbbbxx
                          <- empty line
aaaaaccccbbbxx
i write my code as:

Code: Select all

	scanf("%d", &test);
	for(count = 0; count < test; ++count)
	{
		scanf(" %[^\n]", s);
		scanf(" %[^\n]", p);
      .........
      .........
   }

Posted: Mon Nov 28, 2005 11:38 am
by smilitude
i changed my code, as you told. still i got wa...