結果

問題 No.2672 Subset Xor Sum
ユーザー ks2mks2m
提出日時 2024-03-15 21:58:14
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,103 bytes
コンパイル時間 2,306 ms
コンパイル使用メモリ 78,688 KB
実行使用メモリ 94,880 KB
最終ジャッジ日時 2024-03-15 21:58:27
合計ジャッジ時間 13,157 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
53,996 KB
testcase_01 AC 56 ms
53,984 KB
testcase_02 AC 55 ms
53,984 KB
testcase_03 AC 55 ms
53,956 KB
testcase_04 AC 57 ms
53,972 KB
testcase_05 AC 56 ms
53,984 KB
testcase_06 AC 56 ms
53,992 KB
testcase_07 AC 56 ms
53,980 KB
testcase_08 AC 55 ms
53,984 KB
testcase_09 AC 56 ms
53,988 KB
testcase_10 AC 56 ms
53,972 KB
testcase_11 AC 57 ms
53,992 KB
testcase_12 AC 57 ms
53,968 KB
testcase_13 AC 59 ms
53,968 KB
testcase_14 AC 56 ms
53,980 KB
testcase_15 AC 56 ms
53,976 KB
testcase_16 AC 60 ms
53,984 KB
testcase_17 AC 58 ms
53,984 KB
testcase_18 AC 57 ms
53,980 KB
testcase_19 AC 56 ms
53,992 KB
testcase_20 AC 57 ms
53,980 KB
testcase_21 AC 56 ms
53,972 KB
testcase_22 AC 55 ms
54,000 KB
testcase_23 AC 56 ms
53,992 KB
testcase_24 AC 56 ms
53,988 KB
testcase_25 AC 54 ms
53,976 KB
testcase_26 AC 54 ms
53,976 KB
testcase_27 AC 57 ms
53,984 KB
testcase_28 AC 56 ms
54,004 KB
testcase_29 AC 57 ms
53,968 KB
testcase_30 AC 377 ms
94,760 KB
testcase_31 AC 271 ms
69,284 KB
testcase_32 AC 232 ms
66,136 KB
testcase_33 AC 380 ms
81,032 KB
testcase_34 AC 367 ms
94,828 KB
testcase_35 AC 371 ms
81,984 KB
testcase_36 AC 407 ms
90,516 KB
testcase_37 AC 295 ms
69,976 KB
testcase_38 AC 375 ms
94,248 KB
testcase_39 AC 173 ms
60,996 KB
testcase_40 AC 334 ms
74,508 KB
testcase_41 AC 375 ms
93,952 KB
testcase_42 AC 360 ms
81,520 KB
testcase_43 AC 409 ms
94,880 KB
testcase_44 AC 351 ms
80,644 KB
testcase_45 AC 91 ms
55,272 KB
testcase_46 AC 86 ms
55,160 KB
testcase_47 AC 88 ms
55,160 KB
testcase_48 AC 88 ms
55,012 KB
testcase_49 AC 92 ms
55,408 KB
testcase_50 AC 125 ms
55,644 KB
testcase_51 AC 90 ms
55,264 KB
testcase_52 AC 88 ms
55,264 KB
testcase_53 AC 95 ms
55,416 KB
testcase_54 AC 81 ms
55,008 KB
testcase_55 AC 92 ms
55,412 KB
testcase_56 AC 74 ms
54,744 KB
testcase_57 AC 61 ms
53,984 KB
testcase_58 AC 58 ms
53,984 KB
testcase_59 AC 69 ms
54,776 KB
testcase_60 AC 61 ms
54,000 KB
testcase_61 AC 72 ms
55,000 KB
testcase_62 AC 80 ms
55,028 KB
testcase_63 AC 88 ms
54,996 KB
testcase_64 AC 61 ms
53,984 KB
testcase_65 WA -
testcase_66 AC 55 ms
53,992 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 - 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