結果

問題 No.2672 Subset Xor Sum
ユーザー ks2mks2m
提出日時 2024-03-15 21:53:33
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,102 bytes
コンパイル時間 2,353 ms
コンパイル使用メモリ 78,596 KB
実行使用メモリ 94,840 KB
最終ジャッジ日時 2024-03-15 21:53:47
合計ジャッジ時間 12,926 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
53,972 KB
testcase_01 AC 54 ms
53,972 KB
testcase_02 AC 55 ms
53,964 KB
testcase_03 AC 54 ms
53,972 KB
testcase_04 AC 56 ms
53,976 KB
testcase_05 AC 55 ms
53,980 KB
testcase_06 AC 56 ms
53,992 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 55 ms
53,980 KB
testcase_24 AC 71 ms
53,980 KB
testcase_25 AC 55 ms
53,976 KB
testcase_26 AC 57 ms
53,972 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 55 ms
53,980 KB
testcase_30 AC 383 ms
94,808 KB
testcase_31 AC 282 ms
69,240 KB
testcase_32 AC 234 ms
66,808 KB
testcase_33 AC 349 ms
80,932 KB
testcase_34 AC 392 ms
94,696 KB
testcase_35 AC 365 ms
81,860 KB
testcase_36 AC 367 ms
90,144 KB
testcase_37 AC 285 ms
69,652 KB
testcase_38 AC 374 ms
94,532 KB
testcase_39 AC 194 ms
61,732 KB
testcase_40 AC 324 ms
74,620 KB
testcase_41 AC 376 ms
94,080 KB
testcase_42 AC 358 ms
81,940 KB
testcase_43 AC 374 ms
94,840 KB
testcase_44 AC 352 ms
80,932 KB
testcase_45 AC 78 ms
55,160 KB
testcase_46 RE -
testcase_47 AC 112 ms
55,004 KB
testcase_48 AC 92 ms
55,256 KB
testcase_49 AC 89 ms
55,124 KB
testcase_50 RE -
testcase_51 AC 90 ms
55,288 KB
testcase_52 AC 92 ms
55,384 KB
testcase_53 RE -
testcase_54 RE -
testcase_55 AC 87 ms
55,308 KB
testcase_56 AC 85 ms
54,996 KB
testcase_57 AC 58 ms
53,964 KB
testcase_58 AC 57 ms
53,964 KB
testcase_59 AC 67 ms
54,880 KB
testcase_60 AC 61 ms
53,984 KB
testcase_61 RE -
testcase_62 RE -
testcase_63 AC 78 ms
54,888 KB
testcase_64 RE -
testcase_65 WA -
testcase_66 AC 55 ms
53,988 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;
		}

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

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