-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path11201.cpp.incomplete
More file actions
75 lines (58 loc) · 1.57 KB
/
11201.cpp.incomplete
File metadata and controls
75 lines (58 loc) · 1.57 KB
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
67
68
#include <iostream>
#include <set>
#include <string>
#include <cstring>
#define P(c) (probs[c - 'a'])
using namespace std;
int n, usages[30], num;
string in, odd = "bcdfghjklmnpqrstvwxyz", even = "aeiou";
double probs[30] = { 12.53, 1.42, 4.68, 5.86, 13.68, 0.69, 1.01, 0.70, 6.25, 0.44, 0.00, 4.97, 3.15,
6.71, 8.68, 2.51, 0.88, 6.87, 7.98, 4.63, 3.93, 0.90, 0.02, 0.22, 0.90, 0.52 };
double dfs(int ind, int end) {
if (ind > end) {
num++;
return 0;
}
double total = 0;
if (ind % 2 == 0) {
for (int i = 0; i < even.size(); i++) {
if (usages[even[i] - 'a'] < 2) {
usages[even[i] - 'a']++;
total += ind * P(even[i]) + dfs(ind + 1, end);
usages[even[i] - 'a']--;
}
}
} else {
for (int i = 0; i < odd.size(); i++) {
if (usages[odd[i] - 'a'] < 2) {
usages[odd[i] - 'a']++;
total += ind * P(odd[i]) + dfs(ind + 1, end);
usages[odd[i] - 'a']--;
}
}
}
return total;
}
double rating() {
double total = 0;
for (int i = 0; i < in.size(); i++)
total += (i + 1) * P(in[i]);
return total;
}
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> in;
num = 0;
memset(usages, 0, sizeof(usages));
usages[in[0] - 'a']++;
double average = dfs(2, in.size());
average += num * P(in[0]);
double r = rating();
cout << in.size() << ' ' << average << ' ' << num << ' ' << average/num << ' ' << r << endl;
average /= num;
if (r < average) cout << "below" << endl;
else cout << "above or equal" << endl;
}
return 0;
}