結果
| 問題 |
No.184 たのしい排他的論理和(HARD)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-16 00:09:18 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 91 ms / 5,000 ms |
| コード長 | 1,033 bytes |
| コンパイル時間 | 1,479 ms |
| コンパイル使用メモリ | 130,556 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-16 00:09:23 |
| 合計ジャッジ時間 | 5,034 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <bitset>
#include <ranges>
using namespace std;
using ll = long long;
auto range(int n) { return views::iota(0, n); }
const int M = 100000;
const int N = 62;
using Row = bitset<M>;
Row A[N];
int main() {
int m; cin >> m;
for (int j : range(m)) {
ll a; cin >> a;
for (int i : range(N)) A[i][j] = (a >> i) & 1;
}
int piv = 0;
for (int j : range(m)) {
bool found = 0;
for (int i : views::iota(piv, N)) {
if (A[i][j]) {
found = 1;
swap(A[i], A[piv]);
break;
}
}
if (!found) {
int parity = 0;
for (int i : range(piv)) parity ^= A[i][j];
continue;
}
for (int i : range(N)) if (i != piv) {
if (A[i][j]) A[i] ^= A[piv];
}
piv++;
}
const int s = piv; // s is the rank of [A[0] A[1] ... A[m - 1]]
ll ans = 1LL << s;
cout << ans << endl;
}