結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー 小指が強い人小指が強い人
提出日時 2016-01-06 01:23:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3,573 ms / 5,000 ms
コード長 583 bytes
コンパイル時間 682 ms
コンパイル使用メモリ 72,024 KB
実行使用メモリ 4,664 KB
最終ジャッジ日時 2023-09-11 23:02:55
合計ジャッジ時間 15,965 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 3,573 ms
4,664 KB
testcase_08 AC 1,576 ms
4,376 KB
testcase_09 AC 1,091 ms
4,380 KB
testcase_10 AC 1,325 ms
4,380 KB
testcase_11 AC 1,740 ms
4,380 KB
testcase_12 AC 6 ms
4,452 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1,797 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 393 ms
4,380 KB
testcase_18 AC 2,675 ms
4,464 KB
testcase_19 AC 192 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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