結果

問題 No.1876 Xor of Sum
ユーザー 👑 hos.lyrichos.lyric
提出日時 2022-03-12 19:03:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 393 ms / 2,000 ms
コード長 1,354 bytes
コンパイル時間 929 ms
コンパイル使用メモリ 103,024 KB
実行使用メモリ 5,288 KB
最終ジャッジ日時 2023-10-17 04:22:09
合計ジャッジ時間 9,506 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
5,280 KB
testcase_01 AC 8 ms
5,280 KB
testcase_02 AC 9 ms
5,280 KB
testcase_03 AC 163 ms
5,284 KB
testcase_04 AC 273 ms
5,288 KB
testcase_05 AC 39 ms
5,284 KB
testcase_06 AC 386 ms
5,288 KB
testcase_07 AC 44 ms
5,284 KB
testcase_08 AC 40 ms
5,284 KB
testcase_09 AC 256 ms
5,288 KB
testcase_10 AC 137 ms
5,284 KB
testcase_11 AC 325 ms
5,288 KB
testcase_12 AC 160 ms
5,284 KB
testcase_13 AC 236 ms
5,288 KB
testcase_14 AC 198 ms
5,284 KB
testcase_15 AC 220 ms
5,288 KB
testcase_16 AC 33 ms
5,284 KB
testcase_17 AC 351 ms
5,288 KB
testcase_18 AC 386 ms
5,288 KB
testcase_19 AC 387 ms
5,288 KB
testcase_20 AC 388 ms
5,288 KB
testcase_21 AC 388 ms
5,288 KB
testcase_22 AC 393 ms
5,288 KB
testcase_23 AC 385 ms
5,288 KB
testcase_24 AC 383 ms
5,288 KB
testcase_25 AC 384 ms
5,288 KB
testcase_26 AC 388 ms
5,288 KB
testcase_27 AC 388 ms
5,288 KB
testcase_28 AC 388 ms
5,288 KB
testcase_29 AC 387 ms
5,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }


constexpr int LIM = 4'000'010;
bitset<LIM> bs;

int N;
vector<int> A;

int main() {
  for (; ~scanf("%d", &N); ) {
    A.resize(N);
    for (int i = 0; i < N; ++i) {
      scanf("%d", &A[i]);
    }
    
    bs.reset();
    bs[0] = 1;
    for (int i = 0; i < N; ++i) {
      bs ^= bs << A[i];
    }
    
    int ans = 0;
    for (int x = 1; x < LIM; ++x) if (bs[x]) {
      ans ^= x;
    }
    
    printf("%d\n", ans);
  }
  return 0;
}
0