結果
問題 | No.803 Very Limited Xor Subset |
ユーザー | moricup |
提出日時 | 2020-10-16 00:03:16 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,198 bytes |
コンパイル時間 | 1,982 ms |
コンパイル使用メモリ | 174,060 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 20:09:49 |
合計ジャッジ時間 | 2,865 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 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 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 2 ms
5,376 KB |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | AC | 2 ms
5,376 KB |
testcase_39 | AC | 2 ms
5,376 KB |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | AC | 2 ms
5,376 KB |
testcase_45 | AC | 2 ms
5,376 KB |
testcase_46 | AC | 1 ms
5,376 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; //typedef typedef unsigned int UINT; typedef unsigned long long ULL; typedef long long LL; typedef long double LD; typedef pair<LL, LL> PLL; typedef tuple<LL, LL, LL> TLL3; typedef tuple<LL, LL, LL, LL> TLL4; typedef set<LL, greater<LL> > setdownLL; #define PQ priority_queue typedef PQ<LL, vector<LL>, greater<LL> > pqupLL; //container utill #define ALL(v) (v).begin(),(v).end() #define CR [](auto element1, auto element2){return element1>element2;} #define LB lower_bound #define UP upper_bound #define PB push_back #define MP make_pair #define MT make_tuple //constant #define PI 3.141592653589793 const int MAX_ROW = 340; // to be set appropriately const int MAX_COL = 30+10; // 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];} }; ostream& operator << (ostream& s, BitMatrix A) { s << endl; for (int i = 0; i < A.H; ++i) { for (int j = 0; j < A.W; ++j) { s << A[i][j] << ", "; } s << endl; } return s; } inline BitMatrix operator * (BitMatrix A, BitMatrix B) { BitMatrix R(A.H, B.W); BitMatrix tB(B.W, B.H); for (int i = 0; i < tB.H; ++i) for (int j = 0; j < tB.W; ++j) tB[i][j] = B[j][i]; for (int i = 0; i < R.H; ++i) for (int j = 0; j < R.W; ++j) R[i][j] = ((A[i] & tB[j]).count() & 1); return R; } inline BitMatrix pow(BitMatrix A, long long n) { BitMatrix R(A.H, A.H); for (int i = 0; i < A.H; ++i) R[i][i] = 1; while (n > 0) { if (n & 1) R = R * A; A = A * A; n >>= 1; } return R; } 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, vector<int> &res) { 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; // answer res.assign(n, 0); for (int i = 0; i < rank; ++i) res[i] = M[i][n]; return rank; } const int MOD = 1000000007; long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } int main() { //input LL N,M,X; cin >> N >> M >> X; LL A[N]; LL i,j; for(i=0; i<N; i++){ cin >> A[i]; } long long ty[M], l[M], r[M]; for(i=0; i<M; i++){ cin >> ty[i] >> l[i] >> r[i]; l[i]--, r[i]--; } //calc vector<int> b; for(i=0; i<30; i++){ if(X%2==1){ b.PB(1); }else{ b.PB(0); } X/=2; } for(i=0; i<M; i++){ b.PB(ty[i]); } BitMatrix AA(30+M,N); for(j=0; j<N; j++){ for(i=0; i<30; i++){ if(A[j]%2==1){ AA[i][j]=1; }else{ AA[i][j]=0; } A[j]/=2; } } for(i=0; i<M; i++){ for(j=0; j<N; j++){ if(l[i]<=j&&j<=r[i]){ AA[i+30][j]=1; }else{ AA[i+30][j]=0; } } } vector<int> c; LL rk=linear_equation(AA,b,c); LL ans; if(rk>=0){ ans=1; for(i=0; i<N-rk; i++){ ans*=2; ans%=MOD; } }else{ ans=0; } //output cout << ans << endl; return 0; }