結果
問題 |
No.183 たのしい排他的論理和(EASY)
|
ユーザー |
![]() |
提出日時 | 2018-05-13 15:11:19 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 819 ms / 5,000 ms |
コード長 | 766 bytes |
コンパイル時間 | 1,032 ms |
コンパイル使用メモリ | 67,972 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-30 06:43:57 |
合計ジャッジ時間 | 6,063 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include <iostream> #include <iomanip> #include <vector> #include <bitset> using namespace std; int main() { const int size = 40000; int n; cin >> n; vector<int> ns(n); for (auto &&x: ns) cin >> x; bitset<size+1> memo; for (int y = 0; y<(n+1); y++) { for (int x = 0; x<size+1; x++) { if (y==0 && x==0) memo[x] = true; else if (y==0) memo[x] = false; else memo[x] = memo[x] || (((x^ns[y-1]) < size) ? memo[x^ns[y-1]] : false); } } // for (int x = 0; x<25; x++) cout << setw(3) << x; cout << endl; // for (int x = 0; x<25; x++) cout << setw(3) << memo[x]; cout << endl; int cnt = 0; for (int x = 0; x<size+1; x++) cnt += memo[x]; cout << cnt << endl; }