結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー GrenacheGrenache
提出日時 2016-02-14 18:44:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,125 ms / 5,000 ms
コード長 766 bytes
コンパイル時間 4,004 ms
コンパイル使用メモリ 73,180 KB
実行使用メモリ 60,812 KB
最終ジャッジ日時 2023-09-11 23:29:39
合計ジャッジ時間 15,354 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
55,292 KB
testcase_01 AC 165 ms
55,492 KB
testcase_02 AC 169 ms
55,740 KB
testcase_03 AC 168 ms
55,800 KB
testcase_04 AC 166 ms
55,744 KB
testcase_05 AC 173 ms
56,184 KB
testcase_06 AC 164 ms
55,364 KB
testcase_07 AC 1,125 ms
59,944 KB
testcase_08 AC 995 ms
60,132 KB
testcase_09 AC 782 ms
60,232 KB
testcase_10 AC 876 ms
60,044 KB
testcase_11 AC 1,047 ms
59,860 KB
testcase_12 AC 169 ms
56,064 KB
testcase_13 AC 131 ms
55,300 KB
testcase_14 AC 849 ms
59,272 KB
testcase_15 AC 1,115 ms
60,812 KB
testcase_16 AC 164 ms
55,784 KB
testcase_17 AC 412 ms
56,816 KB
testcase_18 AC 1,019 ms
60,340 KB
testcase_19 AC 307 ms
56,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;


public class Main_yukicoder183 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        boolean[][] dp = new boolean[2][16384 * 2 + 1];
        dp[0][0] = true;

        for (int i = 1; i <= n; i++) {
        	int a = sc.nextInt();

    		Arrays.fill(dp[i % 2], false);

        	for (int j = 0; j <= 16384 * 2; j++) {
        		if (dp[(i - 1) % 2][j]) {
            		dp[i % 2][j] = true;
        			dp[i % 2][j ^ a] = true;
        		}
        	}
        }

        int ret = 0;
        for (boolean f : dp[n % 2]) {
        	if (f) {
        		ret++;
        	}
        }

        System.out.println(ret);

        sc.close();
    }
}
0