結果
問題 | No.2895 Zero XOR Subset |
ユーザー | Katu2ou |
提出日時 | 2024-09-20 22:44:56 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 10,317 bytes |
コンパイル時間 | 4,473 ms |
コンパイル使用メモリ | 237,168 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-09-20 22:45:11 |
合計ジャッジ時間 | 10,013 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 6 ms
9,216 KB |
testcase_01 | AC | 7 ms
9,344 KB |
testcase_02 | WA | - |
testcase_03 | AC | 7 ms
9,344 KB |
testcase_04 | AC | 6 ms
9,344 KB |
testcase_05 | AC | 7 ms
9,216 KB |
testcase_06 | WA | - |
testcase_07 | AC | 7 ms
9,216 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 8 ms
9,216 KB |
testcase_11 | AC | 7 ms
9,216 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 7 ms
9,344 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 6 ms
9,344 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 7 ms
9,344 KB |
testcase_21 | AC | 6 ms
9,216 KB |
testcase_22 | WA | - |
testcase_23 | AC | 7 ms
9,216 KB |
testcase_24 | AC | 7 ms
9,216 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 7 ms
9,216 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | AC | 7 ms
9,216 KB |
testcase_36 | WA | - |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; #define rep2(i, m, n) for (int i = (m); i < (n); ++i) #define rep(i, n) rep2(i, 0, n) #define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i) #define drep(i, n) drep2(i, n, 0) #define all(...) std::begin(__VA_ARGS__), std::end(__VA_ARGS__) #define rall(...) std::rbegin(__VA_ARGS__), std::rend(__VA_ARGS__) #define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i) #define REV(i, a, b) for (int i = (a); i >= (b); --i) #define CLR(a, b) memset((a), (b), sizeof(a)) #define DUMP(x) cout << #x << " = " << (x) << endl; #define INF 1001001001001001001ll #define inf (int)1001001000 #define MOD 998244353 #define MOD1 1000000007 #define PI 3.14159265358979 #define Dval 1e-12 #define fcout cout << fixed << setprecision(12) #define Mp make_pair #define pb push_back #define fi first #define se second #define SORT(x) sort(x.begin(),x.end()) #define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end()) #define POSL(x,v) (distance(x.begin(),lower_bound(x.begin(),x.end(),v)-x.begin())) #define POSU(x,v) (distance(x.begin(),upper_bound(x.begin(),x.end(),v)-x.begin())) using ll = long long; using ld = long double; using vi = vector<int>; using vl = vector<long long>; using vs = vector<string>; using vd = vector<double>; using vld = vector<long double>; using vc = vector<char>; using vb = vector<bool>; using vpii = vector<pair<int, int>>; using vpil = vector<pair<int, long long>>; using vpll = vector<pair<long long, long long>>; using vvi = vector<vector<int>>; using vvl = vector<vector<long long>>; using vvd = vector<vector<double>>; using vvld = vector<vector<long double>>; using vvc = vector<vector<char>>; using vvb = vector<vector<bool>>; using vvpii = vector<vector<pair<int,int>>>; using vvpll = vector<vector<pair<long long,long long>>>; using vvvi = vector<vector<vector<int>>>; using vvvl = vector<vector<vector<long long>>>; using pii = pair<int, int>; using pll = pair<long long, long long>; using LL = __int128_t; using mint = atcoder::modint998244353; using vmint = vector<mint>; using vvmint = vector<vector<mint>>; using vvvmint = vector<vector<vector<mint>>>; ll gcd(ll x, ll y) { if (x == 0) return y; return gcd(y%x, x);} ll lcm(ll x, ll y) { __int128_t xx,yy; xx=x; yy=y; __int128_t ans=xx * yy / gcd(x, y); ll ans2=ans; return ans; } template<typename T> T POW(T x, ll n){T ret=1; while(n>0){ if(n&1) ret=ret*x; x=x*x; n>>=1; } return ret;} template<typename T> T modpow(T a, ll n, T p) { if(n==0) return (T)1; if (n == 1) return a % p; if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p; T t = modpow(a, n / 2, p); return (t * t) % p;} template<typename T> T modinv(T a, T m) { if(m==0)return (T)1; T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u;} template<typename T> T REM(T a, T b){ return (a % b + b) % b;} template<typename T> T QUO(T a, T b){ return (a - REM(a, b)) / b;} ll rand_int(ll l, ll r) { //[l, r] //#ifdef LOCAL static mt19937_64 gen; /*#else static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count()); #endif*/ return uniform_int_distribution<ll>(l, r)(gen); } /* const int MAXCOMB=510000; ll MODCOMB = 998244353; ll fac[MAXCOMB], finv[MAXCOMB], inv[MAXCOMB]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAXCOMB; i++) { fac[i] = fac[i - 1] * i % MODCOMB; inv[i] = MODCOMB - inv[MODCOMB%i] * (MODCOMB / i) % MODCOMB; finv[i] = finv[i - 1] * inv[i] % MODCOMB; }} ll COM(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MODCOMB) % MODCOMB;} ll com(ll n,ll m){ if(n<m || n<=0 ||m<0){ return 0; } if( m==0 || n==m){ return 1; } ll k=1; for(ll i=1;i<=m;i++){ k*=(n-i+1); k%=MODCOMB; k*=modinv(i,MODCOMB); k%=MODCOMB; } return k;} */ const int MAXCOMB=510000; std::vector<mint> FAC(MAXCOMB), FINV(MAXCOMB), INV(MAXCOMB); void COMinit() {FAC[0] = FAC[1] = 1;FINV[0] = FINV[1] = 1;INV[1] = 1;for (int i = 2; i < MAXCOMB; i++) {FAC[i] = FAC[i - 1] * i;INV[i] = mint(0) - INV[mint::mod() % i] * (mint::mod() / i);FINV[i] = FINV[i - 1] * INV[i];}} mint COM(int n, int k) {if (n < k) return 0;if (n < 0 || k < 0) return 0;return FAC[n] * FINV[k] * FINV[n - k];} template <typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false));} template <typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false));} template <class T> T BS(vector<T> &vec, T key) { auto itr = lower_bound(vec.begin(), vec.end(), key); return distance(vec.begin(), itr); } template<class T> pair<T,T> RangeBS(vector<T> &vec, T lowv, T highv){auto itr_l = lower_bound(vec.begin(), vec.end(), lowv); auto itr_r = upper_bound(vec.begin(), vec.end(), highv); return make_pair(distance(vec.begin(), itr_l), distance(vec.begin(), itr_r)-1);} void fail() { cout << "-1\n"; exit(0); } void no() { cout << "No\n"; exit(0); } void yes() { cout << "Yes\n"; exit(0); } template<class T> void er(T a) { cout << a << '\n'; exit(0); } int dx[] = { 1,0,-1,0,1,1,-1,-1 }; int dy[] = { 0,1,0,-1,1,-1,1,-1}; bool range_in(int i, int j, int h, int w){ if(i<0 || j<0 || i>=h || j>=w) return false; return true;} int bitcount(int n){n=(n&0x55555555)+(n>>1&0x55555555); n=(n&0x33333333)+(n>>2&0x33333333); n=(n&0x0f0f0f0f)+(n>>4&0x0f0f0f0f); n=(n&0x00ff00ff)+(n>>8&0x00ff00ff); n=(n&0x0000ffff)+(n>>16&0x0000ffff); return n;} template<typename T> struct Edge{ int from, to, index; T cost; Edge() : from(-1), to(-1), index(-1), cost(0) {} Edge(int _to) : from(-1), to(_to), index(-1), cost(0) {} Edge(int _to, T _cost) : from(-1), to(_to), index(-1), cost(_cost) {} Edge(int _from, int _to, int _index) : from(_from), to(_to), index(_index), cost(0) {} Edge(int _from, int _to, int _index, T _cost) : from(_from), to(_to), index(_index), cost(_cost) {} bool operator<(const Edge<T>& other) const { return cost < other.cost; } Edge &operator=(const int &x) { to = x; return *this; } operator int() const { return to; } }; using Graph = vector<vector<int>>; template <typename T> using WGraph = vector<vector<Edge<T>>>; ////////////////////////////////////////////////////////////////////////////////////////// namespace std { template <size_t N> bool operator<(const bitset<N> &a, const bitset<N> &b) { int f = (a ^ b)._Find_first(); return f == N ? false : a[f]; } } // namespace std template <size_t H_MAX, size_t W_MAX> struct F2_Matrix { using Mat = F2_Matrix; int H, W; array<bitset<W_MAX>, H_MAX> A; vector<vector<int>> index; vector<int> firsth; F2_Matrix(int h = H_MAX, int w = W_MAX) : H(h), W(w), index(H_MAX), firsth(H_MAX) { assert(0 <= h and h <= (int)H_MAX); assert(0 <= w and w <= (int)W_MAX); for (int i = 0; i < (int)H_MAX; i++) A[i].reset(); for(int i=0;i<(int)H_MAX;i++)firsth[i]=i; } inline bitset<W_MAX> &operator[](int i) { return A[i]; } inline const bitset<W_MAX> &operator[](int i) const { return A[i]; } static Mat I(int n) { Mat a(n, n); for (int i = 0; i < n; i++) a[i][i] = true; return a; } // (AND, XOR) 半環 // (AND, OR) 半環には operator/ を割り当てた Mat &operator*=(const Mat &B) { Mat C(H, B.W); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (A[i][j]) C[i] ^= B[j]; } } swap(A, C.A); return *this; } Mat operator*(const Mat &B) const { return Mat(*this) *= B; } // (AND, OR) 半環 friend Mat and_or_product(const Mat &A, const Mat &B) { Mat C(A.H, B.W); for (int i = 0; i < A.H; i++) { for (int j = 0; j < A.W; j++) { if (A[i][j]) C[i] |= B[j]; } } return C; } // [0, wr) の範囲で列を掃き出し, rank を返す(0列目からwr-1列目までの列ベクトルから生成される空間の次元) pair<vector<vector<int>>,vector<int>> sweep(int wr = -1) { if (wr == -1) wr = W; int t = 0; for (int u = 0; u < wr; u++) { int piv = -1; for (int i = t; i < H; i++) { if (A[i][u]) { piv = i; break; } } if (piv == -1) continue; if (piv != t) {swap(A[piv], A[t]); swap(index[piv],index[t]); swap(firsth[piv],firsth[t]);} for (int i = 0; i < H; i++) { if (i != t && A[i][u]) {A[i] ^= A[t]; index[i].pb(t); } } t++; } return make_pair(index,firsth); } Mat inverse() const { assert(H == W); int N = H; F2_Matrix<H_MAX, W_MAX * 2> c(H, W * 2); for (int i = 0; i < N; i++) { c[i][i + N] = 1; for (int j = 0; j < N; j++) { c[i][j] = A[i][j]; } } int r = c.sweep(); assert(r == N); Mat b(H, W); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { b[i][j] = c[i][j + N]; } } return b; } int determinant() const { assert(H == W); F2_Matrix<H_MAX, W_MAX> c{*this}; int r = c.sweep(); return r == H ? 1 : 0; } bool operator<(const Mat &rhs) const { if (H != rhs.H) return H < rhs.H; if (W != rhs.W) return W < rhs.W; return A < rhs.A; } bool operator==(const Mat &rhs) const { return H == rhs.H and W == rhs.W and A == rhs.A; } friend ostream &operator<<(ostream &os, const Mat &b) { for (int i = 0; i < b.H; i++) { os << "[ "; for (int j = 0; j < b.W; j++) { os << b[i][j] << ", "; } os << "],\n"; } return os; } }; void solve(){ int N; cin>>N; const int n= N; vl a(n); rep(i,n){ cin>>a[i]; } int H=min(n,61); int W=60; F2_Matrix<61,60> mat; rep(i,H){ mat[i]=a[i]; } auto index=mat.sweep(); rep(i,min(61,n)){ if(mat[i]==0){ cout<<index.fi[i].size()+1<<endl; for(int to:index.fi[i]){ cout<<to+1<<" "; } cout<<index.se[i]+1<<endl; return; } } cout<<-1<<endl; } signed main(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); int TT; TT = 1; //cin >> TT; while(TT--) solve(); }