結果

問題 No.2672 Subset Xor Sum
ユーザー ks2mks2m
提出日時 2024-03-15 21:55:31
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,105 bytes
コンパイル時間 2,193 ms
コンパイル使用メモリ 78,716 KB
実行使用メモリ 95,252 KB
最終ジャッジ日時 2024-03-15 21:55:51
合計ジャッジ時間 12,713 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
53,992 KB
testcase_01 AC 54 ms
53,984 KB
testcase_02 AC 56 ms
53,992 KB
testcase_03 AC 55 ms
53,976 KB
testcase_04 AC 54 ms
53,984 KB
testcase_05 AC 56 ms
53,976 KB
testcase_06 AC 55 ms
53,984 KB
testcase_07 AC 61 ms
53,988 KB
testcase_08 AC 59 ms
53,968 KB
testcase_09 AC 56 ms
53,984 KB
testcase_10 AC 55 ms
53,988 KB
testcase_11 AC 55 ms
53,992 KB
testcase_12 AC 56 ms
53,988 KB
testcase_13 AC 54 ms
53,976 KB
testcase_14 AC 54 ms
53,984 KB
testcase_15 AC 59 ms
53,984 KB
testcase_16 AC 56 ms
53,988 KB
testcase_17 AC 54 ms
53,984 KB
testcase_18 AC 54 ms
53,976 KB
testcase_19 AC 54 ms
53,976 KB
testcase_20 AC 54 ms
53,984 KB
testcase_21 AC 55 ms
53,964 KB
testcase_22 AC 55 ms
53,976 KB
testcase_23 AC 55 ms
53,976 KB
testcase_24 AC 64 ms
53,976 KB
testcase_25 AC 56 ms
53,988 KB
testcase_26 AC 53 ms
53,964 KB
testcase_27 AC 55 ms
51,900 KB
testcase_28 AC 54 ms
53,968 KB
testcase_29 AC 55 ms
53,992 KB
testcase_30 AC 374 ms
94,332 KB
testcase_31 AC 298 ms
69,548 KB
testcase_32 AC 276 ms
66,648 KB
testcase_33 AC 358 ms
80,944 KB
testcase_34 AC 364 ms
94,044 KB
testcase_35 AC 389 ms
83,044 KB
testcase_36 AC 362 ms
90,012 KB
testcase_37 AC 283 ms
69,692 KB
testcase_38 AC 371 ms
94,948 KB
testcase_39 AC 203 ms
61,780 KB
testcase_40 AC 306 ms
72,536 KB
testcase_41 AC 368 ms
95,252 KB
testcase_42 AC 363 ms
81,248 KB
testcase_43 AC 376 ms
94,780 KB
testcase_44 AC 357 ms
80,960 KB
testcase_45 AC 88 ms
53,176 KB
testcase_46 AC 94 ms
55,396 KB
testcase_47 AC 93 ms
55,384 KB
testcase_48 AC 89 ms
55,280 KB
testcase_49 AC 94 ms
55,120 KB
testcase_50 AC 97 ms
55,644 KB
testcase_51 AC 88 ms
55,288 KB
testcase_52 AC 79 ms
53,516 KB
testcase_53 AC 94 ms
55,012 KB
testcase_54 AC 85 ms
55,260 KB
testcase_55 AC 87 ms
55,264 KB
testcase_56 AC 84 ms
54,756 KB
testcase_57 AC 63 ms
53,980 KB
testcase_58 AC 58 ms
53,960 KB
testcase_59 AC 71 ms
54,876 KB
testcase_60 AC 61 ms
53,996 KB
testcase_61 AC 76 ms
54,484 KB
testcase_62 AC 81 ms
54,988 KB
testcase_63 AC 88 ms
54,980 KB
testcase_64 AC 60 ms
54,000 KB
testcase_65 WA -
testcase_66 AC 55 ms
53,984 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[8200];
		dp[0] = true;
		for (int i = 0; i < n; i++) {
			boolean[] wk = Arrays.copyOf(dp, dp.length);
			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