結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー matsu7874matsu7874
提出日時 2015-12-27 21:12:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 141 ms / 5,000 ms
コード長 563 bytes
コンパイル時間 1,288 ms
コンパイル使用メモリ 143,304 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 22:55:32
合計ジャッジ時間 3,320 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 115 ms
4,376 KB
testcase_08 AC 122 ms
4,380 KB
testcase_09 AC 83 ms
4,380 KB
testcase_10 AC 99 ms
4,380 KB
testcase_11 AC 132 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 127 ms
4,380 KB
testcase_15 AC 141 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 32 ms
4,376 KB
testcase_18 AC 114 ms
4,384 KB
testcase_19 AC 17 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// g++ -std=c++0x -O2
#include <bits/stdc++.h>
using namespace std;

#define MAX_V 32768
int main() {
  int N;
  int A[5000];
  int  i, j;
  bool dp[MAX_V];

  scanf("%d", &N);

  for (i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }

  for (i = 1; i < MAX_V; ++i) {
    dp[i] = false;
  }
  dp[0] = true;

  for (i = 0; i < N; ++i) {
    for (j = 0; j < MAX_V; ++j) {
      if (dp[j]) {
        dp[j ^ A[i]] = true;
      }
    }
  }
  int cnt = 0;

  for (i = 0; i < MAX_V; ++i) {
    if (dp[i]) {
      cnt += 1;
    }
  }
  printf("%d\n", cnt);
  return 0;
}
0