499 - What's The Frequency, Kenneth?

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

Moderator: Board moderators

Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
Location: Calgary, Canada

Post by Darko » Thu Jan 05, 2006 1:51 pm

You declare count[51] but you need 52?

Darko

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

Post by =viki= » Thu Jan 05, 2006 2:01 pm

damn thats silly...

neway thanx for the help....

chunyi81
A great helper
Posts: 293
Joined: Sat Jun 21, 2003 4:19 am
Location: Singapore

Post by chunyi81 » Fri Jan 06, 2006 10:51 am

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
But your code prints:

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:

Post by =viki= » Fri Jan 06, 2006 1:50 pm

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

Post by chunyi81 » Fri Jan 06, 2006 2:47 pm

Hint: use gets instead of getchar.

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

Post by =viki= » Fri Jan 06, 2006 4:33 pm

thanx.... i got AC now.

used if(ch==EOF) instead of if(ch=='.')
to break out of loop.

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Mon Jan 09, 2006 4:56 pm

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

Post by vinit_iiita » Fri Jun 30, 2006 12:38 pm

#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
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Fri Jun 30, 2006 9:15 pm

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

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

499- getting WA Plz Helpppppppppppppppp!!!!

Post by dust_cover » Tue Oct 03, 2006 10:36 pm

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

//REMOVED

thnx in advance
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

Post by sunny » Wed Oct 04, 2006 12:50 am

give this input:

Code: Select all

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

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

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

Post by dust_cover » Fri Oct 06, 2006 12:01 pm

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

//removed after AC

Thnnx in advance!
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

Post by sunny » Fri Oct 06, 2006 1:16 pm

no ur program prints:

Code: Select all

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

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

Post by dust_cover » Fri Oct 06, 2006 9:22 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

Post by sklitzz » Thu Oct 12, 2006 12:03 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;
}

Post Reply

Return to “Volume 4 (400-499)”