結果
問題 | No.183 たのしい排他的論理和(EASY) |
ユーザー |
![]() |
提出日時 | 2016-03-25 15:50:23 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 186 ms / 5,000 ms |
コード長 | 1,091 bytes |
コンパイル時間 | 497 ms |
コンパイル使用メモリ | 85,332 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-29 13:13:48 |
合計ジャッジ時間 | 2,333 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
/* -*- coding: utf-8 -*- * * 183.cc: No.183 たのしい排他的論理和(EASY) - yukicoder */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #include<complex> #include<functional> using namespace std; /* constant */ const int MAX_N = 5000; const int MAX_AB = 15; const int ABITS = 1 << MAX_AB; /* typedef */ /* global variables */ int as[MAX_N]; bool dp[2][ABITS]; /* subroutines */ /* main */ int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> as[i]; int cur = 0, nxt = 1; dp[cur][0] = true; for (int i = 0; i < n; i++) { memcpy(dp[nxt], dp[cur], sizeof(dp[cur])); for (int bits = 0; bits < ABITS; bits++) if (dp[cur][bits]) dp[nxt][bits ^ as[i]] = true; cur ^= 1, nxt ^= 1; } int cnt = 0; for (int bits = 0; bits < ABITS; bits++) if (dp[cur][bits]) cnt++; printf("%d\n", cnt); return 0; }