結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー ぴろずぴろず
提出日時 2015-04-17 16:51:08
言語 Java19
(openjdk 21)
結果
AC  
実行時間 267 ms / 5,000 ms
コード長 540 bytes
コンパイル時間 2,684 ms
コンパイル使用メモリ 73,016 KB
実行使用メモリ 62,340 KB
最終ジャッジ日時 2023-09-11 11:04:55
合計ジャッジ時間 7,460 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,348 KB
testcase_01 AC 127 ms
55,968 KB
testcase_02 AC 162 ms
55,656 KB
testcase_03 AC 139 ms
56,072 KB
testcase_04 AC 124 ms
55,360 KB
testcase_05 AC 158 ms
57,888 KB
testcase_06 AC 125 ms
58,156 KB
testcase_07 AC 259 ms
62,248 KB
testcase_08 AC 238 ms
58,816 KB
testcase_09 AC 220 ms
59,628 KB
testcase_10 AC 242 ms
61,324 KB
testcase_11 AC 245 ms
59,316 KB
testcase_12 AC 187 ms
60,372 KB
testcase_13 AC 124 ms
55,812 KB
testcase_14 AC 214 ms
59,180 KB
testcase_15 AC 247 ms
60,084 KB
testcase_16 AC 129 ms
55,908 KB
testcase_17 AC 205 ms
58,880 KB
testcase_18 AC 267 ms
62,340 KB
testcase_19 AC 213 ms
58,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no183;

import java.util.HashSet;
import java.util.Scanner;

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();
		}
		HashSet<Integer> hs = new HashSet<>();
		hs.add(0);
		for(int i=0;i<n;i++) {
			if (!hs.contains(a[i])) {
				HashSet<Integer> hs2 = new HashSet<>();
				for(int j:hs) {
					hs2.add(a[i] ^ j);
				}
				hs.addAll(hs2);
			}
		}
		System.out.println(hs.size());
	}
}
0