結果
問題 | No.2672 Subset Xor Sum |
ユーザー |
|
提出日時 | 2024-03-15 21:29:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 865 bytes |
コンパイル時間 | 1,920 ms |
コンパイル使用メモリ | 195,988 KB |
最終ジャッジ日時 | 2025-02-20 04:38:16 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 66 |
ソースコード
#include <bits/stdc++.h> using namespace std; template<class T> istream& operator >> (istream& is, vector<T>& vec) { for(T& x : vec) is >> x; return is; } template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { if(vec.empty()) return os; os << vec[0]; for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it; return os; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, xorv = 0; cin >> n; vector<int> b; bool flg = false; for(int i = 0; i < n; i++){ int v; cin >> v; xorv ^= v; if(v == 0){ flg = true; } for(auto &&e : b){ v = min(v, v ^ e); } if(v != 0){ b.push_back(v); } } cout << ((flg || b.size() <= n - 2) && xorv == 0 ? "Yes" : "No") << '\n'; }