結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー 小指が強い人
提出日時 2016-01-09 00:37:29
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1,714 ms / 5,000 ms
コード長 588 bytes
コンパイル時間 485 ms
コンパイル使用メモリ 72,132 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-29 12:33:00
合計ジャッジ時間 7,725 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <unordered_map>
using namespace std;

int main(void)
{
    int n;
    int a[5000];
    unordered_map<int, bool> dp;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    dp[0] = true;
    for(int i = 0; i < n; i++) {
        unordered_map<int, bool> buf;
        for(auto p : dp) {
            int x = a[i] ^ p.first;
            if(dp.count(x) > 0 || buf.count(x) > 0)
                continue;
            buf[x] = true;
        }
        for(auto t : buf)
            dp[t.first] = true;
    }
    cout << dp.size() << endl;
    return 0;
}
0