-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjain.cpp
50 lines (44 loc) · 1.11 KB
/
jain.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
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
ll test, n;
map<char, int> m;
m['a'] = 1;
m['e'] = 2;
m['i'] = 4;
m['o'] = 8;
m['u'] = 16;
cin >> test;
while(test--){
cin >> n;
string s[n];
set<char> st;
std::vector<ll> arr(32);
for(ll i = 0; i < n; i++){
cin >> s[i];
ll sum = 0;
st.insert(s[i].begin(), s[i].end());
set<char>::iterator it;
for(it=st.begin(); it!=st.end(); it++){
sum+=m[*it];
}
arr[sum]++;
st.clear();
}
ll answer = 0;
for(ll i = 1; i < 31; i++){
for(ll j = i+1; j <= 31; j++){
if((int)(i|j) == 31)
answer += (arr[i]*arr[j]);
cerr << answer << " " << i << " " << j << "\n";
}
}
answer += (arr[31]*(arr[31] - 1))/2;
cout << answer << "\n";
for(ll i = 1; i < 32; i++){
cerr << arr[i] << " ";
}
}
return 0;
}