10062 - Tell me the frequencies!
Moderator: Board moderators
Re: 10062 - Tell Me the Frequencies!
Shuvrothpol1
your code give the wrong answer for this:
Try this >>>
111122223333 555 4 AAAA
52 1
53 3
32 3
65 4
51 4
50 4
49 4
NOTE: Read carefully >> "Print the ASCII characters in the ascending order of their frequencies. If two characters are present the same time print the information of the ASCII character with higher ASCII value first"
Thinking easily
your code give the wrong answer for this:
Try this >>>
111122223333 555 4 AAAA
52 1
53 3
32 3
65 4
51 4
50 4
49 4
NOTE: Read carefully >> "Print the ASCII characters in the ascending order of their frequencies. If two characters are present the same time print the information of the ASCII character with higher ASCII value first"
Thinking easily
Last edited by shuvokr on Sun Dec 16, 2012 3:31 pm, edited 1 time in total.
Code: Select all
enjoying life .....
-
- New poster
- Posts: 17
- Joined: Wed Aug 15, 2012 12:37 pm
Re: 10062 - Tell Me the Frequencies!
i think my output is ok of the given input @shuvokr. i think your output of 1st line will be 52 1
Re: 10062 - Tell Me the Frequencies!
You r right shuvrothpol1 >>> sorry for mistak
Code: Select all
enjoying life .....
Re: 10062 - Tell Me the Frequencies!
shuvrothpol1 >>> From your code i got wrong answer>> i hope that when you UPDATE your code for this wrong then you will get ACCEPTED
Input:
your CODE output is:
97 -105
32 -65
120 41
122 104
But the right output is:
122 104
32 191
120 297
97 407
Try by easy thinking >>> Best of luck .....
Input:
Code: Select all
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
97 -105
32 -65
120 41
122 104
But the right output is:
122 104
32 191
120 297
97 407
Try by easy thinking >>> Best of luck .....
Code: Select all
enjoying life .....
-
- New poster
- Posts: 17
- Joined: Wed Aug 15, 2012 12:37 pm
Re: 10062 - Tell Me the Frequencies!
tnx shuvo kr
-
- New poster
- Posts: 9
- Joined: Fri May 04, 2012 9:41 pm
- Location: SUST, Sylhet, Bangladesh
- Contact:
Re: 10062 - Tell Me the Frequencies!
Code: Select all
#include <stdio.h>
#include <string.h>
int main()
{
int len, cnt,i,j,x,max, maxpos;
int list[150];
int print[150][2];
char input[5000];
bool flag = false;
while(gets(input))
{
if(flag) printf("\n");
flag = true;
cnt = 0;
max = 1;
len = strlen(input);
for (i=32; i<129; i++)
{
list[i] = 0;
}
for (i=0; i<len; i++)
{
x = input[i];
list[x]++;
}
while(max!=0)
{
printf("\n"); max = 0;
maxpos = -1;
for (i=32; i<129; i++)
{
if(max<list[i])
{
max = list[i];
maxpos = i;
}
}
if(max!=0)
{
print[cnt][1] = max;
print[cnt++][0] = maxpos;
list[maxpos] = 0;
}
}
for (i = cnt-1; i>=0; i--)
printf("%d %d\n", print[i][0], print[i][1]);
}
return 0;
}
-----
Enamul Hassan,
Student,
2nd year, CSE,
SUST, Sylhet, Bangladesh
Enamul Hassan,
Student,
2nd year, CSE,
SUST, Sylhet, Bangladesh
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10062 - Tell Me the Frequencies!
PM sent
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 39
- Joined: Tue Aug 07, 2012 10:40 pm
- Location: BUBT,Dhaka, Bangladesh
- Contact:
Re: 10062 - Tell Me the Frequencies!
Input:
Output:
Code: Select all
alim
shipu alim anjan
illusion hidden infinity
bubt cse 19th intake
programming contest
jhdf sdk sldfk sdflkh
kdsjghkgkgsgf
Code: Select all
109 1
108 1
105 1
97 1
117 1
115 1
112 1
109 1
108 1
106 1
104 1
110 2
105 2
32 2
97 3
121 1
117 1
116 1
115 1
111 1
104 1
102 1
101 1
108 2
100 2
32 2
110 4
105 6
117 1
115 1
110 1
107 1
105 1
104 1
99 1
97 1
57 1
49 1
101 2
98 2
116 3
32 3
115 1
112 1
105 1
101 1
99 1
97 1
32 1
116 2
114 2
111 2
110 2
109 2
103 2
106 1
108 2
104 2
115 3
107 3
102 3
32 3
100 4
106 1
104 1
102 1
100 1
115 2
107 3
103 4
Give me six hours to chop down a tree and I will spend the first four sharpening the axe...(BUBT ILLUSION)
http://uhunt.felix-halim.net/id/155497
http://onlyprogramming.wordpress.com/
http://uhunt.felix-halim.net/id/155497
http://onlyprogramming.wordpress.com/
10062 - Tell Me the Frequencies!
WA................anyone help me plz.........
Code: Select all
/*************************************
******** Team : BUBT_HIDDEN **********
**************************************
*********** Shipu Ahamed *************
*************************************/
#include<algorithm>
#include<iostream>
#include<iterator>
#include<cassert>
#include<sstream>
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<complex>
#include<string>
#include<cctype>
#include<cstdio>
#include<vector>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<deque>
#include<list>
#include<set>
#include<map>
#define sc scanf
#define pf printf
#define ll long long
#define pi 2*acos(0.0)
#define ff first
#define se second
#define inf (1<<30) //infinity value
#define pb push_back
#define mod 1000000007
#define ST(v) sort(v.begin(),v.end())
#define cover(a,d) memset(a,d,sizeof(a))
#define input freopen("in.txt","r",stdin)
#define output freopen("out.txt","w",stdout)
#define maxall(v) *max_element(v.begin(),v.end())
#define minall(v) *min_element(v.begin(),v.end())
#define un(v) ST(v), v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;
ll gcd(ll a, ll b)
{
if (b==0) return a;
return gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
return a/gcd(a, b)*b;
}
bool cmp(ll a,ll b)
{
return a > b;
}
int main()
{
// input;
// output;
string s;
while(getline(cin,s))
{
int l=s.size();
map<int,int>mp;
map<char,int>mp1;
priority_queue<int>pq;
for(int i=0;i<l;i++)
{
mp[s[i]]++;
}
for(int i=0;i<l;i++)
{
if(mp1[s[i]]==0){
pq.push(-mp[s[i]]);
mp1[s[i]]++;
}
}
while(!pq.empty())
{
map<int,int>:: iterator it;
int a=-pq.top();
for(it=mp.end();;it--)
{
if(a==it->se)
{
cout<<it->ff<<" "<<it->se<<endl;
it->se=0;
break;
}
}
pq.pop();
}
pf("\n");
}
return 0;
}
Nothing is imposible in the world.....And
Never Judge a Book by Its Cover.............
BUBT_Psycho
http://uhunt.felix-halim.net/id/168573
http://shipuahamed.blogspot.com
Never Judge a Book by Its Cover.............
BUBT_Psycho
http://uhunt.felix-halim.net/id/168573
http://shipuahamed.blogspot.com
-
- New poster
- Posts: 39
- Joined: Tue Aug 07, 2012 10:40 pm
- Location: BUBT,Dhaka, Bangladesh
- Contact:
Re: 10062 - Tell Me the Frequencies!
Don't print the new line after last output.....shipu_a wrote:WA................anyone help me plz.........Code: Select all
/************************************* ******** Team : BUBT_HIDDEN ********** ************************************** *********** Shipu Ahamed ************* *************************************/ #include<algorithm> #include<iostream> #include<iterator> #include<cassert> #include<sstream> #include<fstream> #include<cstdlib> #include<cstring> #include<utility> #include<complex> #include<string> #include<cctype> #include<cstdio> #include<vector> #include<bitset> #include<stack> #include<queue> #include<cmath> #include<deque> #include<list> #include<set> #include<map> #define sc scanf #define pf printf #define ll long long #define pi 2*acos(0.0) #define ff first #define se second #define inf (1<<30) //infinity value #define pb push_back #define mod 1000000007 #define ST(v) sort(v.begin(),v.end()) #define cover(a,d) memset(a,d,sizeof(a)) #define input freopen("in.txt","r",stdin) #define output freopen("out.txt","w",stdout) #define maxall(v) *max_element(v.begin(),v.end()) #define minall(v) *min_element(v.begin(),v.end()) #define un(v) ST(v), v.erase(unique(v.begin(),v.end()),v.end()) using namespace std; ll gcd(ll a, ll b) { if (b==0) return a; return gcd(b, a%b); } ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } bool cmp(ll a,ll b) { return a > b; } int main() { // input; // output; string s; while(getline(cin,s)) { int l=s.size(); map<int,int>mp; map<char,int>mp1; priority_queue<int>pq; for(int i=0;i<l;i++) { mp[s[i]]++; } for(int i=0;i<l;i++) { if(mp1[s[i]]==0){ pq.push(-mp[s[i]]); mp1[s[i]]++; } } while(!pq.empty()) { map<int,int>:: iterator it; int a=-pq.top(); for(it=mp.end();;it--) { if(a==it->se) { cout<<it->ff<<" "<<it->se<<endl; it->se=0; break; } } pq.pop(); } pf("\n"); } return 0; }
Give me six hours to chop down a tree and I will spend the first four sharpening the axe...(BUBT ILLUSION)
http://uhunt.felix-halim.net/id/155497
http://onlyprogramming.wordpress.com/
http://uhunt.felix-halim.net/id/155497
http://onlyprogramming.wordpress.com/
Re: 10062 - Tell Me the Frequencies!
thnx..............alimalimbubt wrote:Don't print the new line after last output.....shipu_a wrote:WA................anyone help me plz.........Code: Select all
AC and removed code.
Nothing is imposible in the world.....And
Never Judge a Book by Its Cover.............
BUBT_Psycho
http://uhunt.felix-halim.net/id/168573
http://shipuahamed.blogspot.com
Never Judge a Book by Its Cover.............
BUBT_Psycho
http://uhunt.felix-halim.net/id/168573
http://shipuahamed.blogspot.com
-
- New poster
- Posts: 10
- Joined: Mon Jun 24, 2013 7:39 am
Re: 10062 - Tell Me the Frequencies!
Hi!
I've just set up this code which works w/given test cases, but I'm just getting WA!
Hope someone will find where I'm wrong. Thanks in advance.
I've just set up this code which works w/given test cases, but I'm just getting WA!
Code: Select all
Removed after AC
Last edited by sm_programmer on Tue Jul 02, 2013 1:36 am, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10062 - Tell Me the Frequencies!
A blank line should separate each set of output. Don't print an extra blank line at the end.
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 10
- Joined: Mon Jun 24, 2013 7:39 am
Re: 10062 - Tell Me the Frequencies!
Oh my! You're right, I just missed it!
After some tweaking, I got AC!
I think I should be more careful about those misses (btw, I forgot to diff this, you see...)
Thanks anyway, Brian! I'm just a beginner, so I think it's normal to commit these mistakes!
After some tweaking, I got AC!
I think I should be more careful about those misses (btw, I forgot to diff this, you see...)
Thanks anyway, Brian! I'm just a beginner, so I think it's normal to commit these mistakes!
-
- New poster
- Posts: 16
- Joined: Thu Oct 10, 2013 8:06 am
Re: 10062 - Tell Me the Frequencies!
remove after AC
Last edited by sadmansobhan on Sun Nov 24, 2013 7:02 pm, edited 1 time in total.