結果

問題 No.1876 Xor of Sum
ユーザー tnakao0123tnakao0123
提出日時 2022-03-18 11:23:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 436 ms / 2,000 ms
コード長 718 bytes
コンパイル時間 440 ms
コンパイル使用メモリ 58,872 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 12:20:41
合計ジャッジ時間 9,754 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
6,812 KB
testcase_01 AC 7 ms
6,944 KB
testcase_02 AC 10 ms
6,944 KB
testcase_03 AC 174 ms
6,940 KB
testcase_04 AC 311 ms
6,944 KB
testcase_05 AC 42 ms
6,940 KB
testcase_06 AC 435 ms
6,940 KB
testcase_07 AC 48 ms
6,940 KB
testcase_08 AC 42 ms
6,944 KB
testcase_09 AC 282 ms
6,944 KB
testcase_10 AC 154 ms
6,944 KB
testcase_11 AC 365 ms
6,944 KB
testcase_12 AC 182 ms
6,940 KB
testcase_13 AC 260 ms
6,940 KB
testcase_14 AC 223 ms
6,940 KB
testcase_15 AC 246 ms
6,940 KB
testcase_16 AC 35 ms
6,944 KB
testcase_17 AC 386 ms
6,940 KB
testcase_18 AC 432 ms
6,940 KB
testcase_19 AC 430 ms
6,940 KB
testcase_20 AC 436 ms
6,944 KB
testcase_21 AC 424 ms
6,940 KB
testcase_22 AC 429 ms
6,940 KB
testcase_23 AC 423 ms
6,944 KB
testcase_24 AC 426 ms
6,944 KB
testcase_25 AC 422 ms
6,940 KB
testcase_26 AC 422 ms
6,944 KB
testcase_27 AC 428 ms
6,940 KB
testcase_28 AC 433 ms
6,940 KB
testcase_29 AC 420 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1876.cc:  No.1876 Xor of Sum - yukicoder
 */

#include<cstdio>
#include<bitset>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 2000;
const int MAX_A = 2000;
const int MAX_M = MAX_N * MAX_A;

/* typedef */

/* global variables */

int as[MAX_N];
bitset<MAX_M+1> dp[2];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);

  int cur = 0, nxt = 1;
  dp[cur].set(0);

  for (int i = 0; i < n; i++) {
    dp[nxt] = dp[cur] ^ (dp[cur] << as[i]);
    swap(cur, nxt);
  }

  int sum = 0;
  for (int i = 0; i <= MAX_M; i++)
    sum ^= i * dp[cur].test(i);
  printf("%d\n", sum);
  return 0;
}
0