Page 4 of 7

Posted: Thu Jan 05, 2006 1:51 pm
by Darko
You declare count[51] but you need 52?

Darko

Posted: Thu Jan 05, 2006 2:01 pm
by =viki=
damn thats silly...

neway thanx for the help....

Posted: Fri Jan 06, 2006 10:51 am
by chunyi81
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

Posted: Fri Jan 06, 2006 1:50 pm
by =viki=
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..

Posted: Fri Jan 06, 2006 2:47 pm
by chunyi81
Hint: use gets instead of getchar.

Posted: Fri Jan 06, 2006 4:33 pm
by =viki=
thanx.... i got AC now.

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

Posted: Mon Jan 09, 2006 4:56 pm
by Jan
Try the I/O set. Your code returns wrong...

Input:

Code: Select all

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

Code: Select all

Hh 5
Hope it helps.

mine is even solving it also even then WA

Posted: Fri Jun 30, 2006 12:38 pm
by vinit_iiita
#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;

}

Posted: Fri Jun 30, 2006 9:15 pm
by Jan
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.

499- getting WA Plz Helpppppppppppppppp!!!!

Posted: Tue Oct 03, 2006 10:36 pm
by dust_cover
Can somebuddy tell me wot is the problem with my code? I am repeatedly getting WA :(

//REMOVED

thnx in advance

Posted: Wed Oct 04, 2006 12:50 am
by sunny
give this input:

Code: Select all

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

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

Posted: Fri Oct 06, 2006 12:01 pm
by dust_cover
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!

Posted: Fri Oct 06, 2006 1:16 pm
by sunny
no ur program prints:

Code: Select all

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

Posted: Fri Oct 06, 2006 9:22 pm
by dust_cover
hey sunny thanx a lot. actually i made a mistake of flag initialization. thanx a lot i got AC!

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