結果
| 問題 |
No.2672 Subset Xor Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-19 00:04:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 83 ms / 2,000 ms |
| コード長 | 1,379 bytes |
| コンパイル時間 | 2,029 ms |
| コンパイル使用メモリ | 195,280 KB |
| 実行使用メモリ | 7,328 KB |
| 最終ジャッジ日時 | 2025-03-19 00:04:49 |
| 合計ジャッジ時間 | 6,355 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 66 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream, ostream>::value, Ostream&>::type operator<<(Ostream& os, const Cont& v){
os << "[ ";
for(auto &x : v)
os << x << ' ';
return os << "]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator << (Ostream &os, const pair<Ts...> &p){
return os << "{" << p.first << ", " << p.second << "}";
}
void dbg_cerr() { cerr << "\e[0m\n"; }
template<typename Head, typename... Tail> void dbg_cerr(Head H, Tail... T) { cerr << ' ' << H; dbg_cerr(T...); }
#ifdef LTF
#define DEBUG(...) cerr << "\e[1;31m[" #__VA_ARGS__ "]:", dbg_cerr(__VA_ARGS__)
#else
#define DEBUG(...)
#endif
constexpr int kC = 15;
void Solve() {
int N; cin >> N;
vector<int> a(N);
int xor_sum = 0;
for (auto &x : a) cin >> x, xor_sum ^= x;
if (xor_sum != 0) {
cout << "No\n";
return;
}
array<int, kC> basis{};
int rk = 0;
auto add = [&](int x) {
for (int i = kC - 1; i >= 0; i--) if (x >> i & 1) {
if (!basis[i]) {
basis[i] = x;
rk++;
return;
}
x ^= basis[i];
}
};
for (auto &x : a) add(x);
if (rk >= N - 1) cout << "No\n";
else cout << "Yes\n";
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int T = 1;
// cin >> T;
while (T--) {
Solve();
}
return 0;
}