結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー murabito1129
提出日時 2025-04-19 09:39:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 381 ms / 5,000 ms
コード長 591 bytes
コンパイル時間 2,335 ms
コンパイル使用メモリ 195,540 KB
実行使用メモリ 163,584 KB
最終ジャッジ日時 2025-04-19 09:39:51
合計ジャッジ時間 5,476 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const int MAX = 32768;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  for(int i=0; n>i; ++i) cin >> a[i];
  bool dp[n+1][MAX+1];
  for(int i=0; n>=i; ++i) for(int j=0; MAX>=j; ++j) dp[i][j] = false;
  dp[0][0] = true;
  for(int i=0; n>i; ++i){
    for(int j=0; MAX>=j; ++j){
      if(dp[i][j] == true) dp[i+1][j^a[i]] = true;
      if(dp[i][j] == true) dp[i+1][j] = true;
    }
  }
  int ans = 0;
  for(int i=0; MAX>=i; ++i) ans += dp[n][i];
  cout << ans << endl;
  /*for(int i=0; 10>i; ++i) cout << dp[n][i] << " ";
  cout << endl;*/
}
0