結果

問題 No.183 たのしい排他的論理和(EASY)
コンテスト
ユーザー ぴろず
提出日時 2015-04-17 16:51:08
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 157 ms / 5,000 ms
コード長 540 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,865 ms
コンパイル使用メモリ 84,836 KB
実行使用メモリ 54,888 KB
最終ジャッジ日時 2026-03-18 10:53:13
合計ジャッジ時間 4,743 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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