-
Notifications
You must be signed in to change notification settings - Fork 14
/
10008.cpp
66 lines (62 loc) · 1.27 KB
/
10008.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define FOI(i, A, B) for (i = A; i <= B; i++)
#define FOD(i, A, B) for (i = A; i >= B; i--)
map<char, int> Map;
map<char, int>::iterator it;
bool comp(char A, char B) {
if (Map[A] != Map[B])
return Map[A] > Map[B];
return A < B;
}
int main(){
//freopen("testI.txt", "r", stdin);
//freopen("testO.txt", "w", stdout);
string alfa = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vector< char > Char;
int i, j, N;
FOI(i, 0, 25) Map[alfa[i]] = 0;
cin >> N;
string str;
getline(cin, str);
while (N--) {
getline(cin, str);
int L = str.length() - 1;
FOI(i, 0, L) {
if (isalpha(str[i])) {
char C = toupper(str[i]);
if (Map[C] == 0) Char.push_back(C);
++Map[C];
}
}
}
sort(Char.begin(), Char.end(), comp);
int S = Char.size() - 1;
FOI(i, 0, S)
cout << Char[i] << " " << Map[Char[i]] << endl;
return 0;
}