Submission #8084258


Source Code Expand

#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}


const ll mod = 1e9+7;
template< int mod >
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int) (1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inv();
        return *this;
    }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    
    ModInt inv() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    
    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    
    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    
    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt< mod >(t);
        return (is);
    }
    
    static int get_mod() { return mod; }
};

using mint = ModInt<mod>;
typedef vector<mint> vm;
typedef vector<vm> vvm;
typedef vector<vvm> vvvm;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, K; cin >> N >> K;
    vl A(N);
    rep(i, N){
        cin >> A[i];
    }
    sort(ALL(A), greater<ll>());
    vvi mat(30, vi(N, 0));
    for(int i = 29; i >= 0; i--) rep(j, N){
        if(A[j]>>i&1) mat[29-i][j] = 1;
    }
    
    vi Kb(30, 0);
    for(int i = 29; i >= 0; i--) if(K>>i&1){
        Kb[29-i] = 1;
    }
    
    int rnow = 0, cnow = 0;
    while(rnow < 30 && cnow < N){
        ll ridx = -1;
        FOR(r, rnow, 30) if(mat[r][cnow] == 1){
            ridx = r;
            swap(mat[rnow], mat[ridx]);
            swap(Kb[rnow], Kb[ridx]);
            break;
        }
        if(ridx == -1){
            cnow++; continue;
        }
        
        rep(r, 30) if(r != rnow && mat[r][cnow] == 1){
            FOR(c, cnow, N){
                mat[r][c] ^= mat[rnow][c];
            }
        }
        rnow++; cnow++;
    }
    
    FOR(r, rnow, 30) if(Kb[r] == 1){
        cout << 0 << endstr; return 0;
    }
    
    cout << mint(2).pow(N-rnow) << endstr;
    return 0;
}

Submission Info

Submission Time
Task F - Limited Xor Subset
User k_k_hiroki
Language C++14 (GCC 5.4.1)
Score 0
Code Size 5711 Byte
Status WA
Exec Time 19 ms
Memory 13184 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 3
AC × 26
WA × 7
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 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_1.txt AC 1 ms 256 KB
subtask_1_10.txt AC 1 ms 384 KB
subtask_1_11.txt WA 1 ms 256 KB
subtask_1_12.txt AC 1 ms 256 KB
subtask_1_13.txt AC 1 ms 256 KB
subtask_1_14.txt AC 1 ms 256 KB
subtask_1_15.txt AC 1 ms 256 KB
subtask_1_16.txt AC 1 ms 256 KB
subtask_1_17.txt AC 1 ms 256 KB
subtask_1_18.txt AC 14 ms 8960 KB
subtask_1_19.txt WA 8 ms 4736 KB
subtask_1_2.txt AC 1 ms 256 KB
subtask_1_20.txt AC 1 ms 384 KB
subtask_1_21.txt AC 1 ms 384 KB
subtask_1_22.txt AC 1 ms 256 KB
subtask_1_23.txt WA 1 ms 256 KB
subtask_1_24.txt WA 1 ms 256 KB
subtask_1_25.txt AC 19 ms 13184 KB
subtask_1_26.txt AC 1 ms 256 KB
subtask_1_27.txt AC 1 ms 256 KB
subtask_1_28.txt WA 1 ms 256 KB
subtask_1_29.txt AC 1 ms 256 KB
subtask_1_3.txt WA 1 ms 256 KB
subtask_1_30.txt WA 1 ms 256 KB
subtask_1_4.txt AC 1 ms 256 KB
subtask_1_5.txt AC 1 ms 256 KB
subtask_1_6.txt AC 10 ms 5504 KB
subtask_1_7.txt AC 3 ms 1792 KB
subtask_1_8.txt AC 2 ms 512 KB
subtask_1_9.txt AC 1 ms 384 KB