結果

問題 No.1091 Range Xor Query
ユーザー bluemeganebluemegane
提出日時 2020-06-24 17:11:57
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 880 bytes
コンパイル時間 1,144 ms
コンパイル使用メモリ 63,440 KB
実行使用メモリ 46,112 KB
最終ジャッジ日時 2023-09-16 21:08:16
合計ジャッジ時間 8,545 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

using System.Text;
using System;

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var q = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, q, a);
    }
    static void getAns(int n, int q, int[] a)
    {
        var sb = new StringBuilder();
        var b = new int[n];
        b[0] = 0 ^ a[0];
        for (int i = 1; i < n; i++)
            b[i] = b[i - 1] ^ a[i];
        for (int i = 0; i < q; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var L = int.Parse(line[0]) - 1;
            var r = int.Parse(line[1]) - 1;
            sb.Append(L == 0 ? b[r].ToString() + "\n" : (b[r] ^ b[L - 1]).ToString() + "\n");
        }
    }
}
0