UVA 12582 - Wedding of Sultan UVA • Sep 1, 2020 Problem PDFSolution:#include<cstdio> #include<cstring> #include<string> #include<cmath> #include<iostream> #include<cctype> #include<map> #include<stack> #include<cstdlib> #include <queue> #include <vector> #include<algorithm> #define ll long long #define sc scanf #define pf printf #define Pi 2*acos(0.0) using namespace std; int main() { map<char,int>mp; stack<char>stk; int t,no=0; string s; cin>>t; while(t--) { cin>>s; stk.push(s[0]); for(int i=1;i<s.size();i++) { if(stk.top()==s[i]) stk.pop(); else { mp[stk.top()]++; stk.push(s[i]); mp[stk.top()]++; } } sort(s.begin(),s.end()); s.erase(unique(s.begin(),s.end()),s.end()); pf("Case %d\n",++no); for(int i=0;i<s.size();i++) pf("%c = %d\n",s[i],mp[s[i]]); mp.clear(); } return 0 ; }https://github.com/Shipu/OnlineJudgeProblemSolutionWithCPlusPlus/tree/master/uva/12582/12582.cpp Tags UVA Competitive Programming Shipu Ahamed Recommended for you UVA UVA 913 - Joana and the Odd Numbers 4 years ago • 1 min read UVA UVA 871 - Counting Cells in a Blob 4 years ago • 3 min read UVA UVA 866 - Intersecting Line Segments 4 years ago • 3 min read