結果

問題 No.1876 Xor of Sum
ユーザー milanis48663220milanis48663220
提出日時 2023-07-05 01:33:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 518 ms / 2,000 ms
コード長 1,587 bytes
コンパイル時間 993 ms
コンパイル使用メモリ 117,620 KB
実行使用メモリ 5,136 KB
最終ジャッジ日時 2023-09-26 00:29:19
合計ジャッジ時間 12,769 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
4,864 KB
testcase_01 AC 8 ms
4,876 KB
testcase_02 AC 10 ms
4,876 KB
testcase_03 AC 208 ms
5,000 KB
testcase_04 AC 355 ms
5,108 KB
testcase_05 AC 48 ms
4,844 KB
testcase_06 AC 498 ms
4,844 KB
testcase_07 AC 56 ms
4,872 KB
testcase_08 AC 49 ms
4,940 KB
testcase_09 AC 329 ms
4,836 KB
testcase_10 AC 176 ms
5,080 KB
testcase_11 AC 422 ms
4,872 KB
testcase_12 AC 207 ms
4,872 KB
testcase_13 AC 310 ms
5,012 KB
testcase_14 AC 262 ms
4,872 KB
testcase_15 AC 288 ms
5,136 KB
testcase_16 AC 41 ms
4,996 KB
testcase_17 AC 457 ms
4,928 KB
testcase_18 AC 506 ms
4,836 KB
testcase_19 AC 518 ms
4,812 KB
testcase_20 AC 504 ms
4,800 KB
testcase_21 AC 507 ms
4,876 KB
testcase_22 AC 501 ms
4,868 KB
testcase_23 AC 517 ms
5,012 KB
testcase_24 AC 509 ms
4,840 KB
testcase_25 AC 501 ms
4,880 KB
testcase_26 AC 499 ms
5,104 KB
testcase_27 AC 504 ms
4,880 KB
testcase_28 AC 510 ms
5,136 KB
testcase_29 AC 507 ms
4,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#include <bitset>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

using bs = bitset<2000*2000+1>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n; cin >> n;
    bs dp;
    dp[0] = 1;
    for(int i = 0; i < n; i++){
        int x; cin >> x;
        dp = dp^(dp<<x);
    }
    int ans = 0;
    for(int x = 0; x <= 2000*2000; x++){
        if(dp[x] == 1) ans ^= x;
    }
    cout << ans << endl;
}
0