結果

問題 No.1456 Range Xor
ユーザー tentententen
提出日時 2021-04-13 09:07:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 357 ms / 2,000 ms
コード長 1,528 bytes
コンパイル時間 2,339 ms
コンパイル使用メモリ 75,208 KB
実行使用メモリ 62,756 KB
最終ジャッジ日時 2023-09-11 13:02:36
合計ジャッジ時間 17,458 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,320 KB
testcase_01 AC 43 ms
49,316 KB
testcase_02 AC 44 ms
49,320 KB
testcase_03 AC 296 ms
60,520 KB
testcase_04 AC 307 ms
60,364 KB
testcase_05 AC 314 ms
60,212 KB
testcase_06 AC 316 ms
60,088 KB
testcase_07 AC 357 ms
62,756 KB
testcase_08 AC 312 ms
60,236 KB
testcase_09 AC 313 ms
60,288 KB
testcase_10 AC 299 ms
60,276 KB
testcase_11 AC 170 ms
56,384 KB
testcase_12 AC 117 ms
54,348 KB
testcase_13 AC 219 ms
55,896 KB
testcase_14 AC 186 ms
55,872 KB
testcase_15 AC 279 ms
60,356 KB
testcase_16 AC 270 ms
60,084 KB
testcase_17 AC 240 ms
57,992 KB
testcase_18 AC 188 ms
55,880 KB
testcase_19 AC 238 ms
58,524 KB
testcase_20 AC 266 ms
60,340 KB
testcase_21 AC 228 ms
58,156 KB
testcase_22 AC 247 ms
60,576 KB
testcase_23 AC 207 ms
55,888 KB
testcase_24 AC 152 ms
55,064 KB
testcase_25 AC 207 ms
55,788 KB
testcase_26 AC 254 ms
58,568 KB
testcase_27 AC 250 ms
60,752 KB
testcase_28 AC 193 ms
55,940 KB
testcase_29 AC 341 ms
62,536 KB
testcase_30 AC 297 ms
60,304 KB
testcase_31 AC 175 ms
55,848 KB
testcase_32 AC 172 ms
56,060 KB
testcase_33 AC 222 ms
58,108 KB
testcase_34 AC 302 ms
62,344 KB
testcase_35 AC 237 ms
58,136 KB
testcase_36 AC 288 ms
59,944 KB
testcase_37 AC 327 ms
60,504 KB
testcase_38 AC 146 ms
55,044 KB
testcase_39 AC 253 ms
60,236 KB
testcase_40 AC 302 ms
60,144 KB
testcase_41 AC 70 ms
51,608 KB
testcase_42 AC 127 ms
54,372 KB
testcase_43 AC 43 ms
49,332 KB
testcase_44 AC 43 ms
49,452 KB
testcase_45 AC 43 ms
49,348 KB
testcase_46 AC 44 ms
49,324 KB
testcase_47 AC 44 ms
49,316 KB
testcase_48 AC 43 ms
49,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] arr = new int[n];
        int xor = 0;
        HashMap<Integer, Integer> counts = new HashMap<>();
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            xor ^= arr[i];
            counts.put(xor, counts.getOrDefault(xor, 0) + 1);
        }
        if (counts.containsKey(k)) {
            System.out.println("Yes");
            return;
        }
        xor = 0;
        for (int i = 0; i < n; i++) {
            xor ^= arr[i];
            counts.put(xor, counts.get(xor) - 1);
            if (counts.containsKey(xor ^ k) && counts.get(xor ^ k) > 0) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0