結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー takeya_okinotakeya_okino
提出日時 2017-08-06 19:11:16
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 649 bytes
コンパイル時間 4,408 ms
コンパイル使用メモリ 77,028 KB
実行使用メモリ 740,088 KB
最終ジャッジ日時 2024-04-20 04:01:57
合計ジャッジ時間 41,001 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
53,528 KB
testcase_01 AC 141 ms
53,268 KB
testcase_02 AC 139 ms
56,236 KB
testcase_03 AC 136 ms
56,232 KB
testcase_04 AC 123 ms
54,280 KB
testcase_05 AC 141 ms
56,376 KB
testcase_06 AC 120 ms
53,448 KB
testcase_07 MLE -
testcase_08 MLE -
testcase_09 AC 3,048 ms
497,360 KB
testcase_10 MLE -
testcase_11 MLE -
testcase_12 AC 131 ms
55,440 KB
testcase_13 AC 122 ms
53,780 KB
testcase_14 MLE -
testcase_15 MLE -
testcase_16 AC 143 ms
56,308 KB
testcase_17 AC 1,236 ms
216,984 KB
testcase_18 MLE -
testcase_19 AC 688 ms
127,248 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, 15)];
    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, 15); 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, 15); j++) {
      if(dp[N - 1][j] > 0) ans++;
    }
    System.out.println(ans);
  }
}
0