Saleh127

UVA 12582

May 13th, 2021
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. test
  11. {
  12. string a;
  13. vector<char>s[200];
  14. stack<char>x;
  15.  
  16. cin>>a;
  17.  
  18. x.push(a[0]);
  19.  
  20. for(ll i=1;i<a.size();i++)
  21. {
  22. if(x.top()==a[i]) x.pop();
  23. else
  24. {
  25. s[x.top()].push_back(a[i]);
  26. s[a[i]].push_back(x.top());
  27. x.push(a[i]);
  28. }
  29. }
  30. cout<<"Case "<<cs<<endl;
  31. for(char ss='A' ; ss<='Z';ss++)
  32. {
  33. if(s[ss].size())
  34. {
  35. cout<<ss<<" = "<<s[ss].size()<<endl;
  36. }
  37. }
  38.  
  39.  
  40. }
  41.  
  42.  
  43. return 0;
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment