Submission #19372711


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;

int main(){
    int n, k;
    cin >> n >> k;

    map<int,int> table;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;

        if(table.find(a) == table.end()) table[a] = 0;
        table[a] += 1;
    }

    vector<long long int> pow2(n+1);
    pow2[0] = 1;
    for(int i=0; i<n; i++){
        pow2[i+1] = pow2[i] * 2;
        pow2[i+1] %= MOD;
    }

    int m = table.size();// < 500 since (1+500) * 500 / 2 > 1e5
    vector<vector<long long int>> dp(m+1,vector<long long int>(1<<17));
    dp[0][0] = 1;
    int i = 0;
    for(auto t : table){
        int x = t.first;
        int num = t.second;

        for(int j=0; j<(1<<17); j++){
            dp[i+1][j] += dp[i][j] * pow2[num-1];// nC0 + nC2 + ... = [(1+1)^n + (1+(-1))^n] / 2 = 2^{n-1}
            dp[i+1][j] %= MOD;

            assert((j^x) < (1<<17));
            dp[i+1][j^x] += dp[i][j] * pow2[num-1];// nC1 + nC3 + ... = [(1+1)^n - (1+(-1))^n] / 2 = 2^{n-1}
            dp[i+1][j^x] %= MOD;
        }
        i += 1;
    }
    cout << dp[m][k] << endl;
    return 0;
}

Submission Info

Submission Time
Task F - Limited Xor Subset
User probably
Language C++ (GCC 9.2.1)
Score 0
Code Size 1172 Byte
Status MLE
Exec Time 493 ms
Memory 463872 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 3
AC × 31
MLE × 2
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_1.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_2.txt, subtask_1_20.txt, subtask_1_21.txt, subtask_1_22.txt, subtask_1_23.txt, subtask_1_24.txt, subtask_1_25.txt, subtask_1_26.txt, subtask_1_27.txt, subtask_1_28.txt, subtask_1_29.txt, subtask_1_3.txt, subtask_1_30.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt, subtask_1_8.txt, subtask_1_9.txt
Case Name Status Exec Time Memory
sample_01.txt AC 12 ms 7404 KB
sample_02.txt AC 9 ms 6408 KB
sample_03.txt AC 16 ms 12316 KB
subtask_1_1.txt AC 22 ms 18556 KB
subtask_1_10.txt AC 35 ms 27560 KB
subtask_1_11.txt AC 34 ms 29680 KB
subtask_1_12.txt AC 34 ms 23680 KB
subtask_1_13.txt AC 32 ms 24660 KB
subtask_1_14.txt AC 24 ms 20452 KB
subtask_1_15.txt AC 25 ms 18476 KB
subtask_1_16.txt AC 16 ms 13472 KB
subtask_1_17.txt AC 9 ms 7348 KB
subtask_1_18.txt AC 21 ms 7880 KB
subtask_1_19.txt AC 16 ms 7648 KB
subtask_1_2.txt AC 32 ms 18556 KB
subtask_1_20.txt MLE 493 ms 463872 KB
subtask_1_21.txt MLE 492 ms 463728 KB
subtask_1_22.txt AC 11 ms 6180 KB
subtask_1_23.txt AC 6 ms 6176 KB
subtask_1_24.txt AC 8 ms 6296 KB
subtask_1_25.txt AC 22 ms 7204 KB
subtask_1_26.txt AC 6 ms 6252 KB
subtask_1_27.txt AC 6 ms 6348 KB
subtask_1_28.txt AC 11 ms 8164 KB
subtask_1_29.txt AC 8 ms 7312 KB
subtask_1_3.txt AC 30 ms 20584 KB
subtask_1_30.txt AC 9 ms 7372 KB
subtask_1_4.txt AC 34 ms 18464 KB
subtask_1_5.txt AC 27 ms 17604 KB
subtask_1_6.txt AC 19 ms 9672 KB
subtask_1_7.txt AC 32 ms 21564 KB
subtask_1_8.txt AC 114 ms 107960 KB
subtask_1_9.txt AC 271 ms 257132 KB