結果

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

ソースコード

diff #

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

int main(void)
{
    int n;
    int a[5000];
    int buf[100000];
    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++) {
        int len = 0;
        for(auto p : dp) {
            int x = a[i] ^ p.first;
            if(dp.count(x) > 0)
                continue;
            buf[len++] = x;
        }
        for(int j = 0; j < len; j++)
            dp[buf[j]] = true;
    }
    cout << dp.size() << endl;
    return 0;
}
0