-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathP10062.cpp
More file actions
31 lines (29 loc) · 737 Bytes
/
P10062.cpp
File metadata and controls
31 lines (29 loc) · 737 Bytes
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
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
typedef std::pair<int,char> Cnt;
int main() {
char c, w[1002];
int counts[129];
bool first = true;
while(gets(w)) {
if(!first)
std::cout << std::endl;
first = false;
for(int i = 32; i <= 128; ++i)
counts[i] = 0;
for(int i = 0; (int)(c = w[i]) > 31; ++i) {
++counts[(int)c];
}
std::vector<Cnt> out;
for(int i = 32; i <= 128; ++i) {
if(counts[i] != 0)
out.push_back(Cnt(counts[i], -i));
}
std::sort(out.begin(), out.end());
for(std::vector<Cnt>::iterator it = out.begin(); it != out.end(); ++it)
std::cout << -((int)it->second) << " " << it->first << std::endl;
}
return 0;
}