結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー matsu7874
提出日時 2015-12-27 21:12:35
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 125 ms / 5,000 ms
コード長 563 bytes
コンパイル時間 2,471 ms
コンパイル使用メモリ 159,036 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-29 12:26:36
合計ジャッジ時間 3,204 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 < 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