結果

問題 No.2672 Subset Xor Sum
ユーザー tentententen
提出日時 2024-03-19 15:03:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 330 ms / 2,000 ms
コード長 1,843 bytes
コンパイル時間 2,343 ms
コンパイル使用メモリ 78,844 KB
実行使用メモリ 68,500 KB
最終ジャッジ日時 2024-03-19 15:03:49
合計ジャッジ時間 13,248 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
53,984 KB
testcase_01 AC 52 ms
53,992 KB
testcase_02 AC 81 ms
54,804 KB
testcase_03 AC 58 ms
53,976 KB
testcase_04 AC 56 ms
53,984 KB
testcase_05 AC 62 ms
54,256 KB
testcase_06 AC 64 ms
54,272 KB
testcase_07 AC 70 ms
54,132 KB
testcase_08 AC 63 ms
54,240 KB
testcase_09 AC 64 ms
54,368 KB
testcase_10 AC 75 ms
54,384 KB
testcase_11 AC 76 ms
54,544 KB
testcase_12 AC 63 ms
54,124 KB
testcase_13 AC 65 ms
54,372 KB
testcase_14 AC 74 ms
54,172 KB
testcase_15 AC 65 ms
54,120 KB
testcase_16 AC 65 ms
54,120 KB
testcase_17 AC 63 ms
54,276 KB
testcase_18 AC 73 ms
54,144 KB
testcase_19 AC 63 ms
54,400 KB
testcase_20 AC 75 ms
54,392 KB
testcase_21 AC 64 ms
54,360 KB
testcase_22 AC 54 ms
54,008 KB
testcase_23 AC 54 ms
53,992 KB
testcase_24 AC 57 ms
53,992 KB
testcase_25 AC 57 ms
53,988 KB
testcase_26 AC 81 ms
54,764 KB
testcase_27 AC 82 ms
54,756 KB
testcase_28 AC 83 ms
54,796 KB
testcase_29 AC 83 ms
54,928 KB
testcase_30 AC 64 ms
54,400 KB
testcase_31 AC 316 ms
67,148 KB
testcase_32 AC 271 ms
59,624 KB
testcase_33 AC 209 ms
59,424 KB
testcase_34 AC 271 ms
61,392 KB
testcase_35 AC 289 ms
66,056 KB
testcase_36 AC 306 ms
65,064 KB
testcase_37 AC 296 ms
66,404 KB
testcase_38 AC 242 ms
61,336 KB
testcase_39 AC 330 ms
68,268 KB
testcase_40 AC 204 ms
59,356 KB
testcase_41 AC 259 ms
61,356 KB
testcase_42 AC 296 ms
66,760 KB
testcase_43 AC 294 ms
64,000 KB
testcase_44 AC 312 ms
68,500 KB
testcase_45 AC 259 ms
61,392 KB
testcase_46 AC 96 ms
55,412 KB
testcase_47 AC 116 ms
55,784 KB
testcase_48 AC 96 ms
55,524 KB
testcase_49 AC 98 ms
53,784 KB
testcase_50 AC 96 ms
55,436 KB
testcase_51 AC 91 ms
55,296 KB
testcase_52 AC 102 ms
55,792 KB
testcase_53 AC 105 ms
55,776 KB
testcase_54 AC 97 ms
55,784 KB
testcase_55 AC 116 ms
55,780 KB
testcase_56 AC 96 ms
55,372 KB
testcase_57 AC 90 ms
55,172 KB
testcase_58 AC 69 ms
54,664 KB
testcase_59 AC 58 ms
53,960 KB
testcase_60 AC 76 ms
52,964 KB
testcase_61 AC 78 ms
54,616 KB
testcase_62 AC 100 ms
55,428 KB
testcase_63 AC 93 ms
54,768 KB
testcase_64 AC 117 ms
55,548 KB
testcase_65 AC 97 ms
55,436 KB
testcase_66 AC 52 ms
54,000 KB
testcase_67 AC 52 ms
53,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int total = 0;
        int[] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = sc.nextInt();
            total ^= values[i];
        }
        if (total != 0) {
            System.out.println("No");
            return;
        }
        Set<Integer> current = new HashSet<>();
        for (int i = 0; i < n - 1; i++) {
            if (current.contains(values[i])) {
                System.out.println("Yes");
                return;
            }
            Set<Integer> next = new HashSet<>();
            for (int x : current) {
                next.add(x ^ values[i]);
            }
            next.add(values[i]);
            current.addAll(next);
        }
        System.out.println("No");
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}
0