結果

問題 No.2895 Zero XOR Subset
ユーザー haihamabossuhaihamabossu
提出日時 2024-09-20 22:10:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,161 bytes
コンパイル時間 2,924 ms
コンパイル使用メモリ 220,892 KB
実行使用メモリ 131,648 KB
最終ジャッジ日時 2024-09-20 22:11:20
合計ジャッジ時間 25,378 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,820 KB
testcase_02 WA -
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 WA -
testcase_07 AC 2 ms
6,944 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 3 ms
6,944 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
6,944 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 3 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 WA -
testcase_23 AC 3 ms
6,944 KB
testcase_24 AC 3 ms
6,940 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
6,940 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 2 ms
6,944 KB
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

void solve() {
  ll n;
  cin >> n;
  vector<bitset<60>> a(n);
  vector<set<ll>> b(n);
  {
    vector<pair<ll, ll>> x(n);
    rep(i, n) cin >> x[i].first, x[i].second = i;
    sort(x.begin(), x.end());
    rep(i, n) a[i] = x[i].first, b[i].insert(x[i].second);
  }
  for (ll j = 59; j >= 0; j--) {
    ll k = -1;
    rep(i, n) {
      if (a[i].test(j)) {
        k = i;
        break;
      }
    }
    if (k == -1)
      continue;
    rep(i, n) if (i != k && a[i].test(j)) {
      a[i] ^= a[k];
      for (const auto x : b[k]) {
        if (b[i].count(x)) {
          b[i].erase(x);
        } else {
          b[i].insert(x);
        }
      }
    }
  }
  rep(k, n) if (a[k].count() == 0) {
    vector<ll> ans(b[k].begin(), b[k].end());
    cout << ans.size() << '\n';
    rep(i, ans.size()) cout << (i ? " " : "") << ans[i] + 1;
    cout << '\n';
    return;
  }
  cout << "-1\n";
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  int T = 1;
  for (int t = 0; t < T; t++) {
    solve();
  }
  return 0;
}
0