結果
問題 |
No.1091 Range Xor Query
|
ユーザー |
![]() |
提出日時 | 2020-10-07 11:53:24 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 22 ms / 2,000 ms |
コード長 | 2,129 bytes |
コンパイル時間 | 224 ms |
コンパイル使用メモリ | 30,336 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 03:19:17 |
合計ジャッジ時間 | 4,391 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 27 |
コンパイルメッセージ
main.c: In function 'main': main.c:6:15: warning: implicit declaration of function 'getc_unlocked' [-Wimplicit-function-declaration] 6 | tmp = getc_unlocked(stdin); \ | ^~~~~~~~~~~~~ main.c:24:5: note: in expansion of macro 'rd_int' 24 | rd_int(n, tmp); | ^~~~~~ main.c:18:19: warning: implicit declaration of function 'putc_unlocked' [-Wimplicit-function-declaration] 18 | while (ptr--) putc_unlocked(buf[ptr] + '0', stdout); | ^~~~~~~~~~~~~ main.c:40:9: note: in expansion of macro 'wt_int' 40 | wt_int(a, buf, ptr); | ^~~~~~
ソースコード
#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, a, l, r, tmp, ptr, acc[200001]; char buf[6]; rd_int(n, tmp); rd_int(q, tmp); acc[0] = 0; for (i = 0; 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; }