Page 15 of 16

Re: 10062 - Tell Me the Frequencies!

Posted: Sun Dec 16, 2012 10:09 am
by shuvokr
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 :P

Re: 10062 - Tell Me the Frequencies!

Posted: Sun Dec 16, 2012 11:07 am
by shuvrothpol1
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!

Posted: Sun Dec 16, 2012 3:31 pm
by shuvokr
:lol: You r right shuvrothpol1 >>> sorry for mistak

Re: 10062 - Tell Me the Frequencies!

Posted: Sun Dec 16, 2012 4:07 pm
by shuvokr
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:

Code: Select all

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa                                                                                                                                                                                               xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
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 .....

Re: 10062 - Tell Me the Frequencies!

Posted: Mon Dec 17, 2012 10:58 pm
by shuvrothpol1
tnx shuvo kr

Re: 10062 - Tell Me the Frequencies!

Posted: Sat Jan 19, 2013 12:02 am
by enamsustcse

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;
}
Where is my misfortune brainfry? :oops: :oops: :oops:

Re: 10062 - Tell Me the Frequencies!

Posted: Sat Jan 19, 2013 1:26 am
by brianfry713
PM sent

Re: 10062 - Tell Me the Frequencies!

Posted: Tue Mar 26, 2013 2:15 pm
by alimbubt
Input:

Code: Select all

alim
shipu alim anjan
illusion hidden infinity
bubt cse 19th intake
programming contest
jhdf sdk sldfk sdflkh
kdsjghkgkgsgf
Output:

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

10062 - Tell Me the Frequencies!

Posted: Wed Mar 27, 2013 5:15 pm
by shipu_a
WA................anyone help me plz......... :( :oops:

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;
}

Re: 10062 - Tell Me the Frequencies!

Posted: Wed Mar 27, 2013 5:25 pm
by alimbubt
shipu_a wrote:WA................anyone help me plz......... :( :oops:

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;
}
Don't print the new line after last output.....

Re: 10062 - Tell Me the Frequencies!

Posted: Wed Mar 27, 2013 5:39 pm
by shipu_a
alimbubt wrote:
shipu_a wrote:WA................anyone help me plz......... :( :oops:

Code: Select all

AC and removed code.
Don't print the new line after last output.....
thnx..............alim

Re: 10062 - Tell Me the Frequencies!

Posted: Sat Jun 29, 2013 4:24 am
by sm_programmer
Hi! :)

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
Hope someone will find where I'm wrong. Thanks in advance. :D

Re: 10062 - Tell Me the Frequencies!

Posted: Tue Jul 02, 2013 12:49 am
by brianfry713
A blank line should separate each set of output. Don't print an extra blank line at the end.

Re: 10062 - Tell Me the Frequencies!

Posted: Tue Jul 02, 2013 1:36 am
by sm_programmer
Oh my! You're right, I just missed it! :roll:

After some tweaking, I got AC! :D
I think I should be more careful about those misses (btw, I forgot to diff this, you see...)

Thanks anyway, Brian! :D I'm just a beginner, so I think it's normal to commit these mistakes!

Re: 10062 - Tell Me the Frequencies!

Posted: Fri Nov 22, 2013 8:13 pm
by sadmansobhan
remove after AC