結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー tentententen
提出日時 2020-10-07 16:49:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 752 ms / 5,000 ms
コード長 677 bytes
コンパイル時間 4,722 ms
コンパイル使用メモリ 71,232 KB
実行使用メモリ 60,748 KB
最終ジャッジ日時 2023-09-27 09:19:02
合計ジャッジ時間 10,564 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
55,796 KB
testcase_01 AC 154 ms
55,652 KB
testcase_02 AC 161 ms
56,052 KB
testcase_03 AC 157 ms
55,668 KB
testcase_04 AC 156 ms
55,852 KB
testcase_05 AC 158 ms
55,976 KB
testcase_06 AC 151 ms
55,524 KB
testcase_07 AC 752 ms
60,280 KB
testcase_08 AC 662 ms
60,188 KB
testcase_09 AC 548 ms
59,996 KB
testcase_10 AC 590 ms
60,072 KB
testcase_11 AC 680 ms
60,356 KB
testcase_12 AC 162 ms
55,968 KB
testcase_13 AC 126 ms
55,960 KB
testcase_14 AC 576 ms
59,048 KB
testcase_15 AC 733 ms
60,748 KB
testcase_16 AC 155 ms
55,492 KB
testcase_17 AC 324 ms
56,756 KB
testcase_18 AC 677 ms
60,356 KB
testcase_19 AC 262 ms
56,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean[] cur = new boolean[1 << 15];
		boolean[] next = new boolean[1 << 15];
		cur[0] = true;
		for (int i = 0; i < n; i++) {
		    int a = sc.nextInt();
		    for (int j = 0; j < (1 <<15); j++) {
		        if (cur[j]) {
		            next[j] = true;
		            next[j ^ a] = true;
		        }
		    }
		    boolean[] tmp = next;
		    next = cur;
		    cur = tmp;
		    Arrays.fill(next, false);
		}
		int count = 0;
		for (boolean b : cur) {
		    if (b) {
		        count++;
		    }
		}
		System.out.println(count);
	}
}
0