結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー takeya_okinotakeya_okino
提出日時 2017-08-06 19:11:52
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 649 bytes
コンパイル時間 1,742 ms
コンパイル使用メモリ 77,432 KB
実行使用メモリ 461,900 KB
最終ジャッジ日時 2024-04-20 04:02:40
合計ジャッジ時間 21,552 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
54,036 KB
testcase_01 AC 115 ms
54,136 KB
testcase_02 AC 122 ms
53,308 KB
testcase_03 AC 120 ms
53,852 KB
testcase_04 AC 108 ms
53,120 KB
testcase_05 AC 124 ms
53,352 KB
testcase_06 AC 121 ms
54,260 KB
testcase_07 WA -
testcase_08 AC 2,101 ms
368,472 KB
testcase_09 AC 1,482 ms
255,148 KB
testcase_10 AC 1,759 ms
289,796 KB
testcase_11 AC 2,256 ms
461,900 KB
testcase_12 WA -
testcase_13 AC 109 ms
53,908 KB
testcase_14 AC 2,372 ms
456,096 KB
testcase_15 AC 2,513 ms
457,224 KB
testcase_16 AC 115 ms
53,500 KB
testcase_17 AC 633 ms
125,428 KB
testcase_18 WA -
testcase_19 AC 387 ms
87,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    for(int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
    }
    int[][] dp = new int[N][(int)Math.pow(2, 14)];
    dp[0][0] = 1;
    dp[0][a[0]] = 1;
    for(int i = 1; i < N; i++) {
      for(int j = 0; j < (int)Math.pow(2, 14); j++) {
        if(dp[i - 1][j] == 1 || dp[i - 1][j ^ a[i]] == 1) dp[i][j] = 1;
      }
    }
    int ans = 0;
    for(int j = 0; j < (int)Math.pow(2, 14); j++) {
      if(dp[N - 1][j] > 0) ans++;
    }
    System.out.println(ans);
  }
}
0