結果
問題 | No.469 区間加算と一致検索の問題 |
ユーザー | bal4u |
提出日時 | 2019-08-11 21:01:08 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 189 ms / 5,000 ms |
コード長 | 1,759 bytes |
コンパイル時間 | 1,862 ms |
コンパイル使用メモリ | 29,540 KB |
実行使用メモリ | 150,308 KB |
最終ジャッジ日時 | 2023-10-12 01:25:45 |
合計ジャッジ時間 | 7,974 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 0 ms
4,352 KB |
testcase_01 | AC | 1 ms
4,352 KB |
testcase_02 | AC | 1 ms
4,352 KB |
testcase_03 | AC | 18 ms
17,224 KB |
testcase_04 | AC | 20 ms
20,260 KB |
testcase_05 | AC | 24 ms
23,164 KB |
testcase_06 | AC | 28 ms
26,764 KB |
testcase_07 | AC | 28 ms
27,804 KB |
testcase_08 | AC | 32 ms
30,692 KB |
testcase_09 | AC | 14 ms
13,792 KB |
testcase_10 | AC | 8 ms
6,720 KB |
testcase_11 | AC | 11 ms
9,856 KB |
testcase_12 | AC | 34 ms
32,436 KB |
testcase_13 | AC | 21 ms
20,416 KB |
testcase_14 | AC | 8 ms
7,332 KB |
testcase_15 | AC | 12 ms
11,916 KB |
testcase_16 | AC | 30 ms
29,028 KB |
testcase_17 | AC | 26 ms
25,456 KB |
testcase_18 | AC | 27 ms
27,004 KB |
testcase_19 | AC | 7 ms
6,212 KB |
testcase_20 | AC | 33 ms
31,500 KB |
testcase_21 | AC | 9 ms
8,480 KB |
testcase_22 | AC | 2 ms
4,352 KB |
testcase_23 | AC | 123 ms
108,408 KB |
testcase_24 | AC | 120 ms
108,312 KB |
testcase_25 | AC | 120 ms
108,268 KB |
testcase_26 | AC | 122 ms
108,104 KB |
testcase_27 | AC | 122 ms
108,860 KB |
testcase_28 | AC | 121 ms
108,600 KB |
testcase_29 | AC | 121 ms
108,468 KB |
testcase_30 | AC | 121 ms
108,304 KB |
testcase_31 | AC | 120 ms
108,108 KB |
testcase_32 | AC | 119 ms
108,656 KB |
testcase_33 | AC | 186 ms
150,032 KB |
testcase_34 | AC | 185 ms
150,200 KB |
testcase_35 | AC | 187 ms
149,956 KB |
testcase_36 | AC | 189 ms
150,308 KB |
testcase_37 | AC | 189 ms
150,008 KB |
testcase_38 | AC | 172 ms
137,712 KB |
testcase_39 | AC | 172 ms
137,908 KB |
testcase_40 | AC | 172 ms
137,956 KB |
testcase_41 | AC | 174 ms
138,232 KB |
testcase_42 | AC | 172 ms
137,848 KB |
testcase_43 | AC | 179 ms
137,100 KB |
testcase_44 | AC | 182 ms
138,092 KB |
testcase_45 | AC | 180 ms
137,580 KB |
testcase_46 | AC | 172 ms
137,744 KB |
testcase_47 | AC | 173 ms
137,700 KB |
testcase_48 | AC | 1 ms
4,352 KB |
testcase_49 | AC | 1 ms
4,368 KB |
testcase_50 | AC | 173 ms
137,944 KB |
testcase_51 | AC | 174 ms
137,484 KB |
コンパイルメッセージ
main.c: 関数 ‘in’ 内: main.c:10:14: 警告: 関数 ‘getchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration] 10 | #define gc() getchar_unlocked() | ^~~~~~~~~~~~~~~~ main.c:18:24: 備考: in expansion of macro ‘gc’ 18 | int n = 0, c = gc(); | ^~ main.c: 関数 ‘out’ 内: main.c:11:15: 警告: 関数 ‘putchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration] 11 | #define pc(c) putchar_unlocked(c) | ^~~~~~~~~~~~~~~~ main.c:31:17: 備考: in expansion of macro ‘pc’ 31 | if (!n) pc('0'); | ^~
ソースコード
// yukicoder: No.469 区間加算と一致検索の問題 // bal4u 2019.8.11 #include <stdio.h> typedef unsigned long long ll; //// 入出力関係 #if 1 #define gc() getchar_unlocked() #define pc(c) putchar_unlocked(c) #else #define gc() getchar() #define pc(c) putchar(c) #endif int in() { // 整数の入力 int n = 0, c = gc(); if (c == '-') { c = gc(); do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return -n; } do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return n; } void out(int n) { // 非負整数の表示(出力) int i; char b[20]; if (!n) pc('0'); else { i = 0; while (n) b[i++] = n % 10 + '0', n /= 10; while (i--) pc(b[i]); } pc('\n'); } //// ハッシュ関数 #define HASHSIZ 9999991 typedef struct { ll s; int id; } HASH; HASH hash[HASHSIZ+5], *hashend = hash + HASHSIZ; int lookup(ll s, int id) { HASH *p = hash + (int)(s % HASHSIZ); while (p->s) { if (p->s == s) return p->id; if (++p == hashend) p = hash; } return id; } void insert(ll s, int id) { HASH *p = hash + (int)(s % HASHSIZ); while (p->s) { if (p->s == s) return; if (++p == hashend) p = hash; } p->s = s, p->id = id; } //// 疑似乱数発生 #if 0 unsigned xorshift() { static unsigned y = 2463534242; y = y ^ (y << 13), y = y ^ (y >> 17), y = y ^ (y << 5); return y; } #endif ll phash[1000005]; const unsigned r = 723471715; int main() { int i, N, Q, x; ll s; N = in(), Q = in(); // r = xorshift(); phash[0] = 1; for (i = 1; i <= N; i++) phash[i] = phash[i-1] * r; s = 0; insert(s+1, 0); for (i = 1; i <= Q; i++) { x = gc(), gc(); if (x == '?') out(lookup(s+1, i)); else { int l = in(), r = in(), k = in(); s += (ll)(phash[r] - phash[l]) * k; insert(s+1, i); } } return 0; }