結果

問題 No.1091 Range Xor Query
ユーザー iiljjiiljj
提出日時 2020-10-07 11:58:40
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 2,128 bytes
コンパイル時間 1,253 ms
コンパイル使用メモリ 29,120 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 09:13:03
合計ジャッジ時間 3,353 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,380 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 11 ms
4,376 KB
testcase_05 AC 14 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 12 ms
4,376 KB
testcase_08 AC 18 ms
4,380 KB
testcase_09 AC 8 ms
4,384 KB
testcase_10 AC 14 ms
4,376 KB
testcase_11 AC 18 ms
4,376 KB
testcase_12 AC 12 ms
4,376 KB
testcase_13 AC 19 ms
4,376 KB
testcase_14 AC 15 ms
4,380 KB
testcase_15 AC 16 ms
4,380 KB
testcase_16 AC 13 ms
4,376 KB
testcase_17 AC 20 ms
4,380 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 5 ms
4,380 KB
testcase_20 AC 17 ms
4,376 KB
testcase_21 AC 8 ms
4,380 KB
testcase_22 AC 17 ms
4,380 KB
testcase_23 AC 14 ms
4,376 KB
testcase_24 AC 15 ms
4,380 KB
testcase_25 AC 15 ms
4,376 KB
testcase_26 AC 15 ms
4,376 KB
testcase_27 AC 16 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘main’ 内:
main.c:6:15: 警告: 関数 ‘getc_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    6 |         tmp = getc_unlocked(stdin);                                                                                    \
      |               ^~~~~~~~~~~~~
main.c:24:5: 備考: in expansion of macro ‘rd_int’
   24 |     rd_int(n, tmp);
      |     ^~~~~~
main.c:18:19: 警告: 関数 ‘putc_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   18 |     while (ptr--) putc_unlocked(buf[ptr] + '0', stdout);
      |                   ^~~~~~~~~~~~~
main.c:40:9: 備考: in expansion of macro ‘wt_int’
   40 |         wt_int(a, buf, ptr);
      |         ^~~~~~

ソースコード

diff #

#include <stdio.h>

// int tmp, var = 0; を先に宣言する
#define rd_int(var, tmp)                                                                                               \
    for (;;) {                                                                                                         \
        tmp = getc_unlocked(stdin);                                                                                    \
        if (tmp < '0' || tmp > '9') break;                                                                             \
        var = var * 10 + tmp - '0';                                                                                    \
    }

// char buf[9]; int ptr = 0; を先に宣言する
#define wt_int(var, buf, ptr)                                                                                          \
    while (var) {                                                                                                      \
        buf[ptr++] = var % 10;                                                                                         \
        var /= 10;                                                                                                     \
    }                                                                                                                  \
    if (!ptr) buf[ptr++] = 0;                                                                                          \
    while (ptr--) putc_unlocked(buf[ptr] + '0', stdout);

int main() {
    int n = 0, q = 0, i = 0, a, l, r, tmp, ptr, acc[200001];
    char buf[6];

    rd_int(n, tmp);
    rd_int(q, tmp);

    acc[0] = 0;
    for (; i < n; ++i) {
        a = 0;
        rd_int(a, tmp);
        acc[i + 1] = acc[i] ^ a;
        // printf("[%d, %d]\n", a, acc[i + 1]);
    }
    for (i = 0; i < q; ++i) {
        ptr = l = r = 0;
        rd_int(l, tmp);
        rd_int(r, tmp);
        a = acc[r] ^ acc[l - 1];
        // printf("<%d %d %d %d %d, %d>\n", i, l, r, acc[r], acc[l - 1], acc[r] ^ acc[l - 1]);
        wt_int(a, buf, ptr);
        putc_unlocked('\n', stdout);
    }
    return 0;
}
0