結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー kyuna
提出日時 2019-08-02 22:14:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 188 ms / 5,000 ms
コード長 507 bytes
コンパイル時間 597 ms
コンパイル使用メモリ 72,696 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-02 15:47:25
合計ジャッジ時間 2,868 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    const int MAX = (1 << 14) * 2 - 1;
    int n; cin >> n;
    vector<int> a(n);
    for (int &ai: a) cin >> ai;
    vector<int> cur(MAX + 1, 0), nxt(MAX + 1, 0);
    cur[0] = 1;
    for (int ai: a) {
        for (int i = 0; i <= MAX; i++) nxt[i] = cur[i ^ ai] | cur[i];
        swap(cur, nxt);
    }
    int ans = 0;
    for (int i = 0; i <= MAX; i++) if (cur[i]) ans++;
    cout << ans << endl;
    return 0;
}
0