10062 - Tell me the frequencies!

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

Moderator: Board moderators

Post Reply
FlyDeath
Learning poster
Posts: 73
Joined: Wed Jan 02, 2002 2:00 am
Location: Taiwan

10062 - Tell me the frequencies!

Post by FlyDeath » Sat Jan 19, 2002 4:46 am

What should the answer be if the input is a blank line??
thanks

ahanys
New poster
Posts: 24
Joined: Mon Nov 19, 2001 2:00 am
Location: N/A
Contact:

Post by ahanys » Mon Mar 04, 2002 11:19 am

No case will be there. You use this imput reading:

char line[1001];
while (gets(line) != NULL) {
// do solution for each line
}

Your problem may be : If two
characters are present the same time print the information of the ASCII character with higher ASCII value first.

Hello

Betovsky
New poster
Posts: 26
Joined: Wed Jun 05, 2002 7:30 pm
Location: Portugal

Post by Betovsky » Wed Jun 05, 2002 8:29 pm

my prog with sample input work great
but on the judge it gives W.A.

does any1 have any ideia of whats te prob?
or knows a better input sample to test ...

Thx

Betovsky
New poster
Posts: 26
Joined: Wed Jun 05, 2002 7:30 pm
Location: Portugal

Post by Betovsky » Thu Jun 13, 2002 1:48 am

this is frustating ...
i was comparing input/output of my prog with a prog of a frined of mine
and it was all the same... but my gets a WA and hes get an aceppted
and we dont know whats wrong. Plzz some find the error ...

[c]

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


int c[96];


void display(){
int i, x, n=99999;

while(n!=0){
for(i=0;i<96;i++){
if(n>c && c!=0){
n=c;
x=i;
continue;
}
if(n==c && x<i){
x=i;
continue;
}
}
if(n==0 || n==99999) break;
printf("%d %d\n", (x+32), n);
c[x]=0;
x = -1;
n = 99999;
}
}


void init(){
int i;

for(i=0;i<96;i++)
c=0;
}

int main(){
char linha[1000];
int check=0, i;


while(fgets(linha,1000,stdin)!=NULL){
if(strlen(linha)==1)
continue;
if(check == 1) printf("\n");
init();
for(i=0;i<strlen(linha)-1;i++){
c[(int) linha -32]++;
}

display();
check=1;
}
return 0;
}

[/c]

Thx..

mook
New poster
Posts: 1
Joined: Tue Aug 20, 2002 2:35 am

Someone discovered?

Post by mook » Tue Aug 20, 2002 2:36 am

Someone discovered what is causing that problem? I have the same problem... with a lot of different algorithms..

arc16
Learning poster
Posts: 62
Joined: Sun Aug 04, 2002 1:05 am
Location: Indonesia

Post by arc16 » Fri Sep 13, 2002 5:30 am

finally found why i get WA for such an easy problem...
the problem desc said that input will be (in ascii value) between 33 - 127, but there will be character outside that limit!!! :evil: After removing my ascii check condition, i get AC...

lendlice
New poster
Posts: 22
Joined: Thu Nov 21, 2002 10:50 am

10062(wrong answer)

Post by lendlice » Thu Nov 21, 2002 11:07 am

I have wrong answer.Who can help me.

Code: Select all

#include<stdio.h>
#include<iostream.h>
#include<string.h>
main()
{
 char a[1000];
 int b[100],c=0,i=0,j=0,n=0,k=0,l=0,m=999,p=0,q=0,r=0,s=0,o=0;
 for(k=0;k<=1000;k++)
     a[k]=0;
 for(k=0;k<=100;k++)
    b[k]=0;
 while(gets(a))
 {
  n=strlen(a);
  for(i=0;i<n;i++)
   {
   if(a[i]>=32&&a[i]<=128)
    {
     j=a[i]-31;
     b[j]++;
    }
  }
for(r=0;r<200;r++)
   {
    if(b[r]!=0)
      s++;
   }
   for(c=0;c<=s;c++)
   {
    for(k=0;k<100;k++)
      {
       if(b[k]<=m && b[k]!=0)
         m=b[k];
      }
    for(k=100;k>0;k--)
      {
       if(m!=999)
	   {	
	    if(b[k]==m)
        {
         o=k+31;
         cout << o;
         cout <<" "<<m<<endl;
         b[k]=0;
         m=999;
         s--;
        }
       }
	}
   }
  
  }

}

deddy one
Experienced poster
Posts: 120
Joined: Tue Nov 12, 2002 7:36 pm

Post by deddy one » Fri Dec 13, 2002 5:08 pm

don't use ascii check in your code , at first I used ascii check too, but it WA, when I removed it , it acc , eventhough mine was PE

deddy one
Experienced poster
Posts: 120
Joined: Tue Nov 12, 2002 7:36 pm

Post by deddy one » Fri Dec 13, 2002 5:15 pm

thx arc16, I got acc after read your post here

takumi
New poster
Posts: 10
Joined: Tue Dec 10, 2002 6:15 pm

10062 WA why??

Post by takumi » Sat Dec 21, 2002 7:29 am

why do my code get a WA i think nothing goes wrong with it???
can any body help me with this.
thanks...
#include <stdio.h>

int main()
{
char input[1001];
int i, temp, ascii[256];

for ( i = 0; i < 1001; i++ ) {
input = 0;
}
for ( i= 0; i < 256; i++ ) {
ascii = 0;
}
while ( gets(input) != NULL) {
for ( i = 0; i < 1001; i++ ) {
temp = input;
ascii[temp]++;
}
if ( input[0] == input[1] ) {
for ( i = 256; i > 1; i-- ) {
if ( ascii != 0 ) {
printf("%d = %d\n", i, ascii );
}
}
}

else {
for ( i = 1; i < 256; i++ ) {
if ( ascii != 0 ) {
printf("%d = %d\n", i, ascii );
}
}
}
for ( i = 0; i < 1001; i++ ) {
input = 0;
}
for ( i= 0; i < 256; i++ ) {
ascii = 0;
}
putchar('\n');

}
return 0;
}[cpp][/cpp][c][/c]

route
New poster
Posts: 39
Joined: Sat Dec 21, 2002 1:25 am

Re: 10062 WA why??

Post by route » Sat Dec 21, 2002 9:07 am

output contains an equal sign

& OUPUT:
AAA
256 = 6553144
65 = 3

??

takumi
New poster
Posts: 10
Joined: Tue Dec 10, 2002 6:15 pm

Post by takumi » Sat Dec 21, 2002 11:47 am

i have change it with no equal sign but still WA
why is that?

route
New poster
Posts: 39
Joined: Sat Dec 21, 2002 1:25 am

RE:

Post by route » Sat Dec 21, 2002 12:08 pm

Actually, your program has some problems

1. the order

input :ABCDEF
output:
70 1
69 1
68 1
67 1
66 1
65 1

notice that the largest ascii value comes first

2. input:
AAA
256 = 6553144 (<---- why is it printed ?)
65 = 3

even when the input is nothing, your program also prints this line...

takumi
New poster
Posts: 10
Joined: Tue Dec 10, 2002 6:15 pm

Post by takumi » Sun Dec 22, 2002 5:40 am

what do I print when I input a blank line
like '\n' or '\t' or should i just ignore it ?

route
New poster
Posts: 39
Joined: Sat Dec 21, 2002 1:25 am

Post by route » Sun Dec 22, 2002 1:31 pm

Whenever there are characters in the input, you should output their ascii values.
I think you should also output a blank line if the input is a blank line.

Post Reply

Return to “Volume 100 (10000-10099)”