## 499 - What's The Frequency, Kenneth?

Moderator: Board moderators

Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
You declare count[51] but you need 52?

Darko

=viki=
New poster
Posts: 23
Joined: Mon Jan 02, 2006 6:23 pm
Contact:
damn thats silly...

neway thanx for the help....

chunyi81
A great helper
Posts: 293
Joined: Sat Jun 21, 2003 4:19 am
Location: Singapore
Your code will still get WA even if the mistake pointed out by Darko is corrected.

Try this input:

Code: Select all

``````When riding your bicycle backwards down a one-way street, if the
wheel falls of a canoe, how many ball bearings does it take to fill
up a water buffalo?
Hello Howard.
Testing
``````
Correct Output is:

Code: Select all

``````e 6
al 7
a 3
Hlo 2
Teginst 1
``````

Code: Select all

``````e 6
al 7
a 3
Hlo 2
``````

=viki=
New poster
Posts: 23
Joined: Mon Jan 02, 2006 6:23 pm
Contact:
i thought the period denotes the end of input....
thats why after Hellow Howard. the program ends..

how should i know when the input ends..

chunyi81
A great helper
Posts: 293
Joined: Sat Jun 21, 2003 4:19 am
Location: Singapore
Hint: use gets instead of getchar.

=viki=
New poster
Posts: 23
Joined: Mon Jan 02, 2006 6:23 pm
Contact:
thanx.... i got AC now.

to break out of loop.

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Contact:
Try the I/O set. Your code returns wrong...

Input:

Code: Select all

``HHHHHh             ................hhhhooooOOO``
Output:

Code: Select all

``Hh 5``
Hope it helps.
Ami ekhono shopno dekhi...
HomePage

vinit_iiita
New poster
Posts: 30
Joined: Mon Jun 19, 2006 10:37 pm
Contact:

### mine is even solving it also even then WA

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main()
{ int i,count,j,n;
char m;
bool flag=true,flag1=true;
string line;
vector<int> v;
vector<char> c,d,p;
while (getline(cin,line))
{

for (i=0;i<line.size();i++){
count=0;
m=line;
for (int ee=0; ee<line.size(); ee++)
{
if (isalpha(line[ee]) && m==line[ee])
count++;
}
v.push_back(count);
c.push_back(m);

}
for(i=0;i<v.size();i++)
{
for(j=0;j<v.size();j++)
if (v<v[j] && flag==true)
flag=false;

if (flag==true)
{d.push_back(c);
count=v;
}
flag=true;
}
for(i=0;i<d.size();i++)
{ m=d;
if(m>(char)64 && m<(char)91)
{ for(j=0;j<p.size();j++)
if(p[j]==m)
flag1=false;
if(flag1)
p.push_back(m);
flag1=true;
}
}
for(i=0;i<d.size();i++)
{ m=d;
if(m>(char)96 && m<(char)123)
{ for(j=0;j<p.size();j++)
if(p[j]==m)
flag1=false;
if(flag1)
p.push_back(m);
flag1=true;
}
}
for(i=0;i<p.size();i++)
cout<<p;
cout<<" "<<count;
p.clear();
c.clear();
d.clear();
v.clear();
cout<<endl;

}

return 0;

}
win

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Contact:
Try the following I/O set...

Input:

Code: Select all

``````bbbAABB.BaaaA
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
zzZZyyAAbb``````
Output:

Code: Select all

``````ABab 3
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1
AZbyz 2``````
Your code returns wrong answer for the third case. Hope it helps.
Ami ekhono shopno dekhi...
HomePage

dust_cover
New poster
Posts: 23
Joined: Tue Sep 12, 2006 9:46 pm

### 499- getting WA Plz Helpppppppppppppppp!!!!

Can somebuddy tell me wot is the problem with my code? I am repeatedly getting WA

//REMOVED

Last edited by dust_cover on Fri Oct 06, 2006 9:26 pm, edited 1 time in total.
i wanna give it a try....

sunny
Experienced poster
Posts: 124
Joined: Sun Sep 11, 2005 10:22 pm
Location: Civil-BUET
give this input:

Code: Select all

``````*/*/*/*/*/
``````
output should be nothing.[/quote]

dust_cover
New poster
Posts: 23
Joined: Tue Sep 12, 2006 9:46 pm

### STill WA plz help!!!!!!!!!!!!!!!!!!!!:(

hi sunny i have checked for */*/*/*/*/. my code outputs nothing
But still getting WA ! could u plz help me?????????????

//removed after AC

Last edited by dust_cover on Fri Oct 06, 2006 9:25 pm, edited 1 time in total.
i wanna give it a try....

sunny
Experienced poster
Posts: 124
Joined: Sun Sep 11, 2005 10:22 pm
Location: Civil-BUET
no ur program prints:

Code: Select all

``````ABC.....XYZabc...xyz 0
``````

dust_cover
New poster
Posts: 23
Joined: Tue Sep 12, 2006 9:46 pm
hey sunny thanx a lot. actually i made a mistake of flag initialization. thanx a lot i got AC!
i wanna give it a try....

sklitzz
New poster
Posts: 32
Joined: Fri Dec 03, 2004 5:19 pm
Hi,

I'm not sure anymore whether I have to print ABC...XYZabc...xyz 0 or a blank line or just skip that one.

Does the above work for blank lines nad those without any characters.
It's a simple task but I'm going crazy tryin figure it out.

Code: Select all

``````#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;

#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define SQ(x) (x)*(x)

string solve( string s ) {
int cnt[52]; memset( cnt, 0, sizeof( cnt ) );
for( int i = 0; i < s.size(); ++i ) {
if( s[i] >= 'a' && s[i] <= 'z' ) cnt[ s[i] - 'a' + 26 ]++;
if( s[i] >= 'A' && s[i] <= 'Z' ) cnt[ s[i] - 'A' ]++;
}

int x = *(max_element( cnt, cnt + 52 ) );

string ret = "";
for( int i = 0; i < 26; ++i ) if( cnt[i] == x ) ret += (i + 'A');
for( int i = 26; i < 52; ++i ) if( cnt[i] == x ) ret += (i + 'a' - 26);

ret += " "; ret += ( x + '0' );

return ret;
}

int main() {
string s;
while( getline( cin, s ) )
cout << solve( s ) << endl;

return 0;
}
``````