// UVa 10008 - What's Cryptanalysis?
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
using namespace std;
struct pa {
char c;
unsigned long long int f;
};
bool operator <(pa a, pa b) {
return a.f > b.f || a.f == b.f && a.c < b.c;
}
int main() {
int n;
cin >> n;
string l;
getline(cin, l);
unsigned long long int m[26];
memset(m, 0, sizeof(m));
for (; n; n--) {
getline(cin, l);
for (int i = 0; i < l.length(); i++) {
if (l[i] >= 'a' && l[i] <= 'z')
l[i] = l[i] - 'a' + 'A';
if (l[i] >= 'A' && l[i] <= 'Z')
m[l[i] - 'A']++;
}
}
vector<pa> v;
for (char ch = 0; ch < 26; ch++)
if (m[ch] > 0) {
pa p = { ch, m[ch] };
v.push_back(p);
}
sort(v.begin(), v.end());
for (int i = 0; i < v.size(); i++)
printf("%c %llu\n", v[i].c + 'A', v[i].f);
return 0;
}
Saturday, June 13, 2015
UVa 10008 - What's Cryptanalysis?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment