結果

問題 No.2895 Zero XOR Subset
ユーザー haihamabossuhaihamabossu
提出日時 2024-09-20 23:21:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,235 bytes
コンパイル時間 2,407 ms
コンパイル使用メモリ 216,592 KB
実行使用メモリ 42,684 KB
最終ジャッジ日時 2024-09-20 23:22:16
合計ジャッジ時間 9,791 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
5,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
5,376 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
5,376 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<vector<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].push_back(x[i].second);
    }
  }
  vector<ll> indeg(n, 0), outdeg(n, 0);
  rep(j, 60) {
    ll k = -1;
    rep(i, n) {
      if (indeg[i] == 0 && outdeg[i] == 0 && a[i].test(j)) {
        k = i;
        outdeg[k] = 1;
        break;
      }
    }
    if (k == -1)
      continue;
    rep(i, n) {
      if (outdeg[i] == 0 && a[i].test(j)) {
        indeg[i] += 1;
        a[i] ^= a[k];
        for (const auto x : b[k]) {
          b[i].push_back(x);
        }
      }
    }
  }
  rep(k, n) if (a[k].count() == 0) {
    sort(b[k].begin(), b[k].end());
    cout << b[k].size() << '\n';
    rep(i, b[k].size()) cout << (i ? " " : "") << b[k][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