結果
問題 | No.803 Very Limited Xor Subset |
ユーザー | kcvlex |
提出日時 | 2019-03-18 15:39:38 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,039 bytes |
コンパイル時間 | 1,551 ms |
コンパイル使用メモリ | 169,592 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-18 10:18:44 |
合計ジャッジ時間 | 3,237 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | WA | - |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | WA | - |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 1 ms
5,376 KB |
testcase_12 | AC | 1 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 | AC | 2 ms
5,376 KB |
testcase_24 | WA | - |
testcase_25 | AC | 2 ms
5,376 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 2 ms
5,376 KB |
testcase_32 | AC | 2 ms
5,376 KB |
testcase_33 | AC | 2 ms
5,376 KB |
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 | AC | 2 ms
5,376 KB |
testcase_42 | WA | - |
testcase_43 | AC | 2 ms
5,376 KB |
testcase_44 | AC | 1 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; //#define DEBUG_MODE #define endl '\n' #ifdef DEBUG_MODE #define DEBUG(X) debug_func(X, #X) #define DEBUG_ENDL endl << flush #define DEBUG_SEPARATOR_LINE cout<<"=================\n" #else #define DEBUG(X) 0 #define DEBUG_ENDL 0 #define DEBUG_SEPARATOR_LINE 0 #endif #define ALL(V) (V).begin(), (V).end() #define ALLR(V) (V).rbegin(), (V).rend() #define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "") << flush; template <typename T> using V = vector<T>; template <typename T> using VV = V<V<T>>; template <typename T, typename U> using P = pair<T, U>; using ll = int64_t; using PLL = P<ll, ll>; template <typename T> const T& var_min(const T &t) { return t; } template <typename T> const T& var_max(const T &t) { return t; } template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); } template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); } template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); } template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); } void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; } template <typename T> void debug_func(const T &t, const string &s = "") { debug_func_preffix(s); cout << t << DEBUG_ENDL_S(s); } template <typename T, typename U> void debug_func(const P<T, U> &p, const string &s = "") { debug_func_preffix(s); cout << "("; debug_func(p.first); cout << ", "; debug_func(p.second); cout << ")" << DEBUG_ENDL_S(s); } template <typename T> void debug_func(const V<T> &v, const string &s = "") { for(ll i = 0; i < v.size(); i++) { string t = s + "[" + to_string(i) + "]"; debug_func(v[i], t); } } void init_io() { cin.tie(0); ios_base::sync_with_stdio(false); cout << fixed << setprecision(30); } using BS = bitset<512>; using Matrix = V<BS>; const ll MOD = 1e9 + 7; tuple<Matrix, BS, ll> gauss_elim(Matrix mat, BS b, ll dim) { ll fcnt = 0; for(ll col = 0; col < dim; col++) { ll row = -1; for(ll r = col; r < mat.size(); r++) { if(mat[r].test(col)) { row = r; break; } } if(row == -1) { fcnt++; continue; } if(row != col) { swap(mat[col], mat[row]); bool tmp = b[col]; b.set(col, b[row]); b.set(row, tmp); } for(ll r = 0; r < mat.size(); r++) { if(r == col) continue; if(!mat[r].test(col)) continue; mat[r] ^= mat[col]; bool tmp = b[r] ^ b[col]; b.set(r, tmp); } } return make_tuple(mat, b, fcnt); } ll calc(Matrix mat, BS b, ll dim) { auto tmp = gauss_elim(mat, b, dim); Matrix gmat; BS gb; ll fcnt; tie(gmat, gb, fcnt) = tmp; #ifdef DEBUG_MODE for(ll i = 0; i < gmat.size(); i++) cout << gmat[i].to_string() << " = " << (gb[i] ? 1 : 0) << endl; #endif for(ll i = 0; i < gmat.size(); i++) if(!gmat[i].any() && gb.test(i)) return 0; ll ret = 1; for(ll i = 0; i < fcnt; i++) (ret *= 2) %= MOD; return ret; } int main() { init_io(); ll N, M, X; cin >> N >> M >> X; BS b(X); Matrix mat(60 + M, BS(0)); ll dim = N; for(ll i = 0; i < N; i++) { ll A; cin >> A; BS ab(A); for(ll dig = 0; dig < 60; dig++) mat[dig][i] = ab.test(dig); } for(ll i = 0; i < M; i++) { ll type, l, r; cin >> type >> l >> r; l--; r--; for(ll j = l; j <= r; j++) mat[i + 60].set(j); b.set(i + 60, !!(type)); } #ifdef DEBUG_MODE for(ll i = 0; i < mat.size(); i++) cout << mat[i].to_string() << " = " << (b[i] ? 1 : 0) << endl; #endif cout << calc(mat, b, dim) << endl; return 0; }