結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー augusuto04augusuto04
提出日時 2015-06-12 06:19:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 289 ms / 5,000 ms
コード長 679 bytes
コンパイル時間 394 ms
コンパイル使用メモリ 58,304 KB
実行使用メモリ 163,404 KB
最終ジャッジ日時 2023-09-11 11:26:40
合計ジャッジ時間 3,379 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 289 ms
145,276 KB
testcase_08 AC 248 ms
145,800 KB
testcase_09 AC 172 ms
101,600 KB
testcase_10 AC 205 ms
122,076 KB
testcase_11 AC 270 ms
159,032 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 230 ms
163,368 KB
testcase_15 AC 278 ms
163,404 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 63 ms
40,428 KB
testcase_18 AC 261 ms
142,564 KB
testcase_19 AC 32 ms
21,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
static const int NMAX = 5000;
static const int AMAX = 16384 * 2;

bool memo[NMAX + 1][AMAX + 1];
int A[NMAX];

int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++)
    cin >> A[i];

  for(int i = 0; i <= N; i++){
    for(int j = 0; j <= AMAX; j++){
      memo[i][j] = false;
    }
  }
  memo[0][0] = 1;

  for(int i = 0; i < N; i++){
    for(int j = 0; j <= AMAX; j++){
      if(memo[i][j]){
        memo[i + 1][(j ^ A[i])] = true;
        memo[i + 1][j] = true;
      }
    }
  }

  int result = 0;
  for(int i = 0; i <= AMAX; i++){
    if(memo[N][i]){
      result++;
    }
  }
  cout << result << endl;
}
0