結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー matsu7874matsu7874
提出日時 2015-12-27 21:10:35
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 559 bytes
コンパイル時間 1,259 ms
コンパイル使用メモリ 159,544 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 11:23:38
合計ジャッジ時間 2,213 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 25 ms
4,348 KB
testcase_09 AC 12 ms
4,348 KB
testcase_10 AC 18 ms
4,348 KB
testcase_11 AC 29 ms
4,348 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 31 ms
4,348 KB
testcase_15 AC 32 ms
4,348 KB
testcase_16 WA -
testcase_17 AC 4 ms
4,348 KB
testcase_18 WA -
testcase_19 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |   scanf("%d", &N);
      |   ~~~~~^~~~~~~~~~
main.cpp:15:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |     scanf("%d", &A[i]);
      |     ~~~~~^~~~~~~~~~~~~

ソースコード

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 < N; ++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