-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSOSdp.cpp
More file actions
45 lines (35 loc) · 933 Bytes
/
SOSdp.cpp
File metadata and controls
45 lines (35 loc) · 933 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// ref: https://codeforces.com/blog/entry/45223
// implementation for https://codeforces.com/problemset/problem/383/E
const int N = 1, LN = 24;
vector<int> F(1 << LN, 0);
vector<int> val(LN + 1);
void compute() {
val[0] = 1;
for (int i = 1; i <= LN; ++i)
val[i] = val[i - 1] * 2ll;
}
void solve() {
int n;
cin >> n;
vector<int> v(n, 0);
string s;
for (int i = 0; i < n; ++i) {
cin >> s;
for (int j = 0; j < 3; ++j)
v[i] |= val[s[j] - 'a'];
}
for (int i = 0; i < n; ++i)
++F[v[i]];
for (int j = 0; j < LN; ++j) {
for (int i = 0; i < val[LN]; ++i) {
if (i & val[j])
F[i] += F[i ^ val[j]];
}
}
int ans = 0, tmp;
for (int i = 1; i < val[LN]; ++i) {
tmp = n - F[(val[LN] - 1) ^ i];
ans ^= (tmp * tmp);
}
cout << ans;
}