-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path1251.cpp
47 lines (41 loc) · 952 Bytes
/
1251.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
void sort(map<int, int> &M)
{
multimap<int, int> MM;
for (auto &it : M)
MM.insert({it.second, it.first});
vector<pair<int, int>> list;
int aux = 1;
for (auto const &it : MM)
{
if (aux != it.first)
{
for (int i = list.size(); i--;)
cout << list[i].second << ' ' << list[i].first << endl;
list.clear();
}
list.push_back(make_pair(it.first, it.second));
aux = it.first;
}
for (int i = list.size(); i--;)
cout << list[i].second << ' ' << list[i].first << endl;
cout << endl;
}
int main()
{
map<int, int> table;
string str;
while (getline(cin, str) && !str.empty())
{
for (auto s : str)
table[int(s)]++;
sort(table);
table.clear();
}
return 0;
}