Uva 10062 – Tell me the frequencies!

Problem Link Solution :- STL Function use করার জন্য সবচেয়ে বেষ্ট প্রবলেম এটা । একটা প্রবলেম অনেক ভাবে করা যাই যদি কেউ STL Function use করা শিখতে চাই তাদের জন্য আমরা কিছু বন্ধু চেষ্টা করেছি যে কিভাবে use করতে হবে সেটা দেখানোর । ১.  map , priority_queue , iterator Tell me the frequencies! - Shipu Ahamed C++ /*------------------------------------------------*/ //Problem Setter: Shahriar Manzoor //Uva Problem No: 10062 //Problem Name : Tell me the frequencies! //Type : Ad hoc,sorting //Author : Shipu Ahamed //University : BUBT //E-mail : shipu@programmer.net /*--------------------------------------------*/ #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; bool cmp(ll a,ll b) { return a > b; } int main() { string s; int f=0; while(getline(cin,s)) { if(f) pf("n"); 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(); } f=1; } return 0; } 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 /*------------------------------------------------*///Problem Setter: Shahriar Manzoor//Uva Problem No: 10062//Problem Name  : Tell me the frequencies!//Type          : Ad hoc,sorting//Author        : Shipu Ahamed//University    : BUBT//E-mail        : shipu@programmer.net/*--------------------------------------------*/ #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...