Submission #1822092


Source Code Expand

Copy
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(x) begin(x), end(x)
using namespace std;

constexpr int mod = 1e9+7;
int main() {
    // input
    int n, k; scanf("%d%d", &n, &k);
    vector<int> a(n); repeat (i, n) scanf("%d", &a[i]);
    // solve
    int limit = accumulate(whole(a), 0, bit_or<int>());
    limit = pow(2, ceil(log2(limit + 1)));
    vector<int> cur(limit);
    cur[0] = 1;
    for (int a_i : a) {
        vector<int> prv = cur;
        repeat (j, limit) {
            cur[j] += prv[j ^ a_i];
            if (cur[j] > mod) cur[j] -= mod;
        }
    }
    // output
    printf("%d\n", cur[k]);
    return 0;
}

Submission Info

Submission Time
Task F - Limited Xor Subset
User kimiyuki
Language C++14 (GCC 5.4.1)
Score 0
Code Size 755 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:15:41: error: ‘bit_or’ was not declared in this scope
     int limit = accumulate(whole(a), 0, bit_or<int>());
                                         ^
./Main.cpp:15:48: error: expected primary-expression before ‘int’
     int limit = accumulate(whole(a), 0, bit_or<int>());
                                                ^
./Main.cpp:12:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     int n, k; scanf("%d%d", &n, &k);
                                    ^
./Main.cpp:13:55: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     vector<int> a(n); repeat (i, n) scanf("%d", &a[i]);
                                                       ^