結果

問題 No.1091 Range Xor Query
ユーザー neko_the_shadowneko_the_shadow
提出日時 2020-07-09 13:20:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,396 ms / 2,000 ms
コード長 3,069 bytes
コンパイル時間 2,735 ms
コンパイル使用メモリ 91,492 KB
実行使用メモリ 80,144 KB
最終ジャッジ日時 2024-04-16 06:31:26
合計ジャッジ時間 30,673 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
38,112 KB
testcase_01 AC 75 ms
37,648 KB
testcase_02 AC 74 ms
38,124 KB
testcase_03 AC 469 ms
52,344 KB
testcase_04 AC 808 ms
50,436 KB
testcase_05 AC 1,184 ms
71,200 KB
testcase_06 AC 255 ms
45,024 KB
testcase_07 AC 1,026 ms
57,908 KB
testcase_08 AC 1,150 ms
60,120 KB
testcase_09 AC 766 ms
48,720 KB
testcase_10 AC 1,027 ms
60,540 KB
testcase_11 AC 1,193 ms
66,900 KB
testcase_12 AC 927 ms
74,856 KB
testcase_13 AC 1,120 ms
57,640 KB
testcase_14 AC 1,021 ms
60,272 KB
testcase_15 AC 1,165 ms
67,364 KB
testcase_16 AC 927 ms
52,296 KB
testcase_17 AC 1,234 ms
60,600 KB
testcase_18 AC 451 ms
47,516 KB
testcase_19 AC 541 ms
53,432 KB
testcase_20 AC 1,113 ms
57,068 KB
testcase_21 AC 725 ms
50,580 KB
testcase_22 AC 1,284 ms
60,612 KB
testcase_23 AC 1,396 ms
80,144 KB
testcase_24 AC 1,223 ms
66,956 KB
testcase_25 AC 1,225 ms
66,900 KB
testcase_26 AC 1,229 ms
66,928 KB
testcase_27 AC 1,368 ms
79,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package _1091;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.lang.reflect.Array;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class Main {
    public void exec() {
        int n = stdin.nextInt();
        int q = stdin.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = stdin.nextInt();

        int[] d = new int[n+1];
        for (int i = 0; i < n; i++) d[i+1] = d[i] ^ a[i];

        for (int i = 0; i < q; i++) {
            int l = stdin.nextInt() - 1;
            int r = stdin.nextInt() - 1;
            stdout.println(d[l] ^ d[r+1]);
        }
    }

    private static final Stdin stdin = new Stdin();
    private static final Stdout stdout = new Stdout();

    public static void main(String[] args) {
        new Main().exec();
        stdout.flush();
    }

    public static class Stdin {
        private BufferedReader stdin;
        private Deque<String> tokens;
        private Pattern delim;

        public Stdin() {
            stdin = new BufferedReader(new InputStreamReader(System.in));
            tokens = new ArrayDeque<>();
            delim = Pattern.compile(" ");
        }

        public String nextString() {
            try {
                if (tokens.isEmpty()) {
                    String line = stdin.readLine();
                    delim.splitAsStream(line).forEach(tokens::addLast);
                }
                return tokens.pollFirst();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public double nextDouble() {
            return Double.parseDouble(nextString());
        }

        public long nextLong() {
            return Long.parseLong(nextString());
        }
    }

    public static class Stdout {
        private PrintWriter stdout;

        public Stdout() {
            stdout =  new PrintWriter(System.out, false);
        }

        public void printf(String format, Object ... args) {
            stdout.printf(format, args);
        }

        public void println(Object ... objs) {
            String line = Arrays.stream(objs).map(this::deepToString).collect(Collectors.joining(" "));
            stdout.println(line);
        }

        private String deepToString(Object o) {
            if (o == null || !o.getClass().isArray()) {
                return Objects.toString(o);
            }

            int len = Array.getLength(o);
            String[] tokens = new String[len];
            for (int i = 0; i < len; i++) {
                tokens[i] = deepToString(Array.get(o, i));
            }
            return "{" + String.join(",", tokens) + "}";
        }

        public void flush() {
            stdout.flush();
        }
    }
}
0