hiho week 254 register

Ended

Participants:81

Verdict:Accepted
Score:100 / 100
Submitted:2019-05-16 14:41:03

Lang:G++

Edit
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 <bits/stdc++.h>
using namespace std;
int f[1 << 20][2];
int main() {
    int T;
    cin >> T;
    while (T--) {
        int N;
        cin >> N;
        for (int i = 0; i < (1 << 20); i++) {
            for (int j = 0; j < 2; j++) {
                f[i][j] = 0;
            }
        }
        while (N--) {
            int a;
            cin >> a;
            if (f[a][0] != 0) {
                f[a][1] = a;
            } else {
                f[a][0] = a;
            }
        }
        long long res = 0;
        for (int j = 19; j >= 0; j--) {
            for (int i = (1 << 20) - 1; i >= 0; i--) {
                if (!(i & (1 << j)) && f[i | (1 << j)][0] > 0) {
                    int z = i | (1 << j);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX