結果
問題 | No.183 たのしい排他的論理和(EASY) |
ユーザー |
![]() |
提出日時 | 2019-08-10 19:31:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4,126 ms / 5,000 ms |
コード長 | 1,193 bytes |
コンパイル時間 | 1,131 ms |
コンパイル使用メモリ | 107,304 KB |
実行使用メモリ | 138,112 KB |
最終ジャッジ日時 | 2024-07-02 15:51:32 |
合計ジャッジ時間 | 20,998 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <stack> #include <queue> #include <list> #include <set> #include <map> #include <numeric> #include <regex> #include <tuple> #include <iomanip> #include <cmath> using namespace std; typedef long long ll; typedef pair<int, int> P; #define MOD 1000000007 // 10^9 + 7 #define INF 1000000000 // 10^9 #define LLINF 1LL<<60 // xor int XOR(int a, int b) { int res = 0; int dig = 1; while ((a > 0) || (b > 0)) { int tmpa = a % 2; int tmpb = b % 2; if (tmpa != tmpb) res += dig; dig *= 2; a /= 2; b /= 2; } return res; } bool poss[5009][32769]; int A[5009]; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; for (int i = 1; i <= N; i++) cin >> A[i]; //cout << "ok1" << endl; //cout << XOR(1, 2) << endl; poss[0][0] = true; for (int i = 0; i < N; i++) { for (int j = 0; j <= 32768; j++) { if (poss[i][j]) { poss[i + 1][j] = true; int nxt = XOR(j,A[i+1]); if (nxt <= 32768) poss[i + 1][nxt] = true; } } } //cout << "ok2" << endl; int ans = 0; for (int j = 0; j <= 32768; j++) { if (poss[N][j]) ans++; } cout << ans << endl; return 0; }