結果
| 問題 | 
                            No.803 Very Limited Xor Subset
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Kiona0405
                         | 
                    
| 提出日時 | 2020-06-12 00:47:32 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,758 bytes | 
| コンパイル時間 | 1,770 ms | 
| コンパイル使用メモリ | 173,948 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-06-24 03:34:01 | 
| 合計ジャッジ時間 | 3,291 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 13 WA * 30 | 
ソースコード
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main()
{
    int N, M, X;
    cin >> N >> M >> X;
    // convert X as vector format
    vector<int> target(400);
    rep(bit, 0, 30)
        if (((1<<bit)&X)>0)
            target[bit] = 1;
    vector<vector<int>> values(N, vector<int>(400, 0));
    rep(i, 0, N)
    {
        int A;
        cin >> A;
        
        int bit = 0;
        rep(bit, 0, 30)
            if (((1<<bit)&A) > 0)
                values[i][bit] = 1;
    }
    
    // restriction
    rep(i, 0, M)
    {
        int t, l, r;
        cin >> t >> l >> r;
        --l, --r;
        target[30+i] = t;
        rep(pos, l, r+1) values[pos][30+i] = 1;
    }
    // sweep method
    int rank = 0;
    vector<int> msb(410, -1);
    rep(bit, 0, 400)
    {
        bool exists = false;
        rep(i, rank, N)
        {
            if (values[i][bit] == 1)
            {
                exists = true;
                // swap
                if (i != rank)
                {
                    rep(j, 0, 400)
                        swap(values[rank][j], values[i][j]);
                }
                break;
            }
        }
        if (!exists) continue;
        // sweep
        // cout << bit << ' ' << rank << endl;
        // pvec(values[rank]);
        rep(i, 0, N)
        {
            if (i==rank) continue;
            if (values[i][bit] == 0) continue;
            rep(j, 0, 400)
                values[i][j] ^= values[rank][j];
            // cout << "add: " << i << endl;
            // pvec(values[i]);
        }
        msb[rank] = bit;
        ++rank;
    }
    // cout << rank << endl;
    //  check ans
    vector<int> status(400, 0);
    rank = 0;
    rep(bit, 0, 400)
    {
        if (target[bit] == 0) continue;
        while (msb[rank]<bit and msb[rank] != -1) ++rank;
        if (msb[rank] == -1 or msb[rank]>bit)
        {
            cout << 0 << endl;
            return 0;
        }
        rep(i,0, 400)
            status[i] ^= values[rank][i];
        ++rank;
    }
    bool is_ok = true;
    rep(bit,0,400)
        if (status[bit]!=target[bit]) is_ok = false;
    if (!is_ok)
    {
        cout << 0 << endl;
        return 0;
    }
    ll cnt = 1;
    rep(i, 0, N)
    {
        bool is_zero = true;
        rep(j,0,400)
            if (values[i][j] == 1) is_zero = false;
        
        if (is_zero) cnt = (cnt*2)%MOD;
    }
    cout << cnt << endl;
    return 0;
}
            
            
            
        
            
Kiona0405