結果

問題 No.2672 Subset Xor Sum
ユーザー ks2mks2m
提出日時 2024-03-15 22:00:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 364 ms / 2,000 ms
コード長 1,128 bytes
コンパイル時間 6,497 ms
コンパイル使用メモリ 77,724 KB
実行使用メモリ 94,816 KB
最終ジャッジ日時 2024-03-16 17:41:43
合計ジャッジ時間 13,275 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
53,984 KB
testcase_01 AC 51 ms
53,988 KB
testcase_02 AC 52 ms
53,984 KB
testcase_03 AC 53 ms
53,968 KB
testcase_04 AC 51 ms
53,992 KB
testcase_05 AC 53 ms
52,012 KB
testcase_06 AC 52 ms
53,972 KB
testcase_07 AC 54 ms
53,988 KB
testcase_08 AC 52 ms
53,964 KB
testcase_09 AC 54 ms
53,992 KB
testcase_10 AC 52 ms
53,972 KB
testcase_11 AC 52 ms
53,972 KB
testcase_12 AC 52 ms
53,976 KB
testcase_13 AC 52 ms
53,968 KB
testcase_14 AC 52 ms
52,032 KB
testcase_15 AC 54 ms
53,952 KB
testcase_16 AC 52 ms
53,972 KB
testcase_17 AC 52 ms
53,964 KB
testcase_18 AC 52 ms
53,988 KB
testcase_19 AC 53 ms
53,972 KB
testcase_20 AC 54 ms
53,960 KB
testcase_21 AC 55 ms
53,984 KB
testcase_22 AC 59 ms
53,984 KB
testcase_23 AC 54 ms
53,988 KB
testcase_24 AC 52 ms
51,884 KB
testcase_25 AC 52 ms
53,960 KB
testcase_26 AC 52 ms
53,972 KB
testcase_27 AC 52 ms
54,000 KB
testcase_28 AC 54 ms
53,980 KB
testcase_29 AC 53 ms
53,984 KB
testcase_30 AC 53 ms
53,972 KB
testcase_31 AC 361 ms
94,384 KB
testcase_32 AC 278 ms
69,556 KB
testcase_33 AC 225 ms
66,364 KB
testcase_34 AC 351 ms
81,164 KB
testcase_35 AC 360 ms
94,256 KB
testcase_36 AC 364 ms
82,292 KB
testcase_37 AC 347 ms
90,136 KB
testcase_38 AC 278 ms
69,816 KB
testcase_39 AC 359 ms
94,564 KB
testcase_40 AC 185 ms
61,884 KB
testcase_41 AC 299 ms
74,500 KB
testcase_42 AC 358 ms
94,816 KB
testcase_43 AC 339 ms
81,920 KB
testcase_44 AC 359 ms
94,168 KB
testcase_45 AC 329 ms
80,548 KB
testcase_46 AC 87 ms
54,992 KB
testcase_47 AC 95 ms
55,388 KB
testcase_48 AC 88 ms
55,288 KB
testcase_49 AC 87 ms
55,292 KB
testcase_50 AC 87 ms
55,152 KB
testcase_51 AC 87 ms
55,016 KB
testcase_52 AC 88 ms
55,196 KB
testcase_53 AC 86 ms
55,132 KB
testcase_54 AC 86 ms
55,260 KB
testcase_55 AC 89 ms
55,656 KB
testcase_56 AC 90 ms
55,392 KB
testcase_57 AC 82 ms
54,776 KB
testcase_58 AC 58 ms
53,980 KB
testcase_59 AC 54 ms
53,976 KB
testcase_60 AC 63 ms
54,632 KB
testcase_61 AC 57 ms
52,044 KB
testcase_62 AC 73 ms
54,776 KB
testcase_63 AC 68 ms
54,860 KB
testcase_64 AC 70 ms
54,752 KB
testcase_65 AC 58 ms
53,984 KB
testcase_66 AC 50 ms
53,980 KB
testcase_67 AC 51 ms
53,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int m = 5000;
		int[] c = new int[m + 1];
		int xor = 0;
		for (int i = 0; i < n; i++) {
			xor ^= a[i];
			c[a[i]]++;
		}
		if (xor != 0) {
			System.out.println("No");
			return;
		}

		if (n > 2) {
			for (int i = 0; i < c.length; i++) {
				if (c[i] >= 2) {
					System.out.println("Yes");
					return;
				}
			}
		}

		boolean[] dp = new boolean[8200];
		dp[0] = true;
		for (int i = 0; i < n - 1; i++) {
			boolean[] wk = Arrays.copyOf(dp, dp.length);
			wk[0] = false;
			for (int j = 0; j < dp.length; j++) {
				if (dp[j]) {
					wk[j ^ a[i]] = true;
				}
			}
			if (wk[0]) {
				System.out.println("Yes");
				return;
			}
			dp = wk;
		}
		System.out.println("No");
	}
}
0