結果
問題 | No.803 Very Limited Xor Subset |
ユーザー | hashiryo |
提出日時 | 2019-04-10 13:05:21 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,059 bytes |
コンパイル時間 | 949 ms |
コンパイル使用メモリ | 102,864 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-07 03:06:39 |
合計ジャッジ時間 | 4,518 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,948 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | AC | 2 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | WA | - |
testcase_35 | RE | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | RE | - |
testcase_42 | RE | - |
testcase_43 | RE | - |
testcase_44 | AC | 2 ms
6,940 KB |
testcase_45 | AC | 2 ms
6,944 KB |
testcase_46 | WA | - |
ソースコード
#include <iostream> #include <cstdio> #include <fstream> #include <algorithm> #include <string> #include <map> #include <set> #include <queue> #include <stack> #include <vector> #include <limits.h> #include <math.h> #include <functional> #include <bitset> #include <iomanip> #include <cassert> #include <float.h> #include <random> #define repeat(i,n) for (int i = 0; (i) < (n); ++ (i)) #define debug(x) cerr << #x << ": " << x << '\n' #define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n' #define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n' using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> Pii; typedef vector<int> vint; typedef vector<ll> vll; const long long INF = INT_MAX; const ll MOD = 1000000009; ll pow_mod(ll x,int n){ if(!n)return 1; ll res=pow_mod(x*x%MOD,n/2); if(n&1)res = res*x%MOD; return res%MOD; } const int MAX_ROW = 310; // to be set appropriately const int MAX_COL = 500; // to be set appropriately struct BitMatrix { int H, W; bitset<MAX_COL> val[MAX_ROW]; BitMatrix(int m = 1, int n = 1) : H(m), W(n) {} inline bitset<MAX_COL>& operator [] (int i) {return val[i];} }; int GaussJordan(BitMatrix &A, bool is_extended = false) { int rank = 0; for (int col = 0; col < A.W; ++col) { if (is_extended && col == A.W - 1) break; int pivot = -1; for (int row = rank; row < A.H; ++row) { if (A[row][col]) { pivot = row; break; } } if (pivot == -1) continue; swap(A[pivot], A[rank]); for (int row = 0; row < A.H; ++row) { if (row != rank && A[row][col]) A[row] ^= A[rank]; } ++rank; } return rank; } int linear_equation(BitMatrix A, vector<int> b) { int m = A.H, n = A.W; BitMatrix M(m, n + 1); for (int i = 0; i < m; ++i) { for (int j = 0; j < n; ++j) M[i][j] = A[i][j]; M[i][n] = b[i]; } int rank = GaussJordan(M, true); // check if it has no solution for (int row = rank; row < m; ++row) if (M[row][n]) return -1; return rank; } ostream &operator<<(ostream &os, BitMatrix &v) { os << "["; for (int i = 0; i < v.H; i++){ if (i > 0) os <<endl<< " "; os << "["; for (int j = 0; j < v.W; os << v[i][j++]) if (j > 0) os << " "; os << "]"; } os << "]"; return os; } int main(){ ll N,M,X;cin>>N>>M>>X; vint b(M+40,0); BitMatrix B(M+40,N); repeat(i,40){ b[i] = (X>>i)&1; } repeat(j,N){ ll A;cin>>A; repeat(i,40){ B[i][j] = (A>>i)&1; } } repeat(i,M){ int l,r;cin>>b[40+i]>>l>>r;l--;r--; for(int j=l;j<=r;j++){ B[40+i][j] = 1; } } //debugArray(b,M+40); //cerr<<B<<endl; int rank = linear_equation(B,b); cout << (rank<0? 0:pow_mod(2,N-rank))<<endl; return 0; }