結果
問題 | No.2592 おでぶなおばけさん 2 |
ユーザー | chro_96 |
提出日時 | 2023-12-20 22:12:48 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 332 ms / 2,500 ms |
コード長 | 2,463 bytes |
コンパイル時間 | 411 ms |
コンパイル使用メモリ | 32,128 KB |
実行使用メモリ | 15,240 KB |
最終ジャッジ日時 | 2024-09-27 10:06:18 |
合計ジャッジ時間 | 26,134 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
9,968 KB |
testcase_01 | AC | 48 ms
11,296 KB |
testcase_02 | AC | 100 ms
10,920 KB |
testcase_03 | AC | 41 ms
10,216 KB |
testcase_04 | AC | 51 ms
10,140 KB |
testcase_05 | AC | 148 ms
13,224 KB |
testcase_06 | AC | 109 ms
10,984 KB |
testcase_07 | AC | 151 ms
11,000 KB |
testcase_08 | AC | 111 ms
11,588 KB |
testcase_09 | AC | 38 ms
10,396 KB |
testcase_10 | AC | 64 ms
9,996 KB |
testcase_11 | AC | 111 ms
12,836 KB |
testcase_12 | AC | 26 ms
10,288 KB |
testcase_13 | AC | 250 ms
12,572 KB |
testcase_14 | AC | 247 ms
12,664 KB |
testcase_15 | AC | 219 ms
11,156 KB |
testcase_16 | AC | 243 ms
12,360 KB |
testcase_17 | AC | 268 ms
12,824 KB |
testcase_18 | AC | 215 ms
12,084 KB |
testcase_19 | AC | 188 ms
10,696 KB |
testcase_20 | AC | 211 ms
12,208 KB |
testcase_21 | AC | 188 ms
10,716 KB |
testcase_22 | AC | 258 ms
13,356 KB |
testcase_23 | AC | 278 ms
12,704 KB |
testcase_24 | AC | 232 ms
12,412 KB |
testcase_25 | AC | 178 ms
10,524 KB |
testcase_26 | AC | 181 ms
10,460 KB |
testcase_27 | AC | 304 ms
13,196 KB |
testcase_28 | AC | 300 ms
13,496 KB |
testcase_29 | AC | 303 ms
13,444 KB |
testcase_30 | AC | 310 ms
13,416 KB |
testcase_31 | AC | 302 ms
13,524 KB |
testcase_32 | AC | 302 ms
13,892 KB |
testcase_33 | AC | 299 ms
13,688 KB |
testcase_34 | AC | 307 ms
13,788 KB |
testcase_35 | AC | 300 ms
13,492 KB |
testcase_36 | AC | 306 ms
14,408 KB |
testcase_37 | AC | 312 ms
13,480 KB |
testcase_38 | AC | 320 ms
13,860 KB |
testcase_39 | AC | 332 ms
13,880 KB |
testcase_40 | AC | 324 ms
13,800 KB |
testcase_41 | AC | 323 ms
14,640 KB |
testcase_42 | AC | 322 ms
13,336 KB |
testcase_43 | AC | 311 ms
13,464 KB |
testcase_44 | AC | 309 ms
13,764 KB |
testcase_45 | AC | 309 ms
14,436 KB |
testcase_46 | AC | 311 ms
13,292 KB |
testcase_47 | AC | 302 ms
13,456 KB |
testcase_48 | AC | 301 ms
14,624 KB |
testcase_49 | AC | 322 ms
14,676 KB |
testcase_50 | AC | 303 ms
14,820 KB |
testcase_51 | AC | 304 ms
13,416 KB |
testcase_52 | AC | 300 ms
14,368 KB |
testcase_53 | AC | 294 ms
13,884 KB |
testcase_54 | AC | 301 ms
13,308 KB |
testcase_55 | AC | 293 ms
14,428 KB |
testcase_56 | AC | 303 ms
13,476 KB |
testcase_57 | AC | 98 ms
14,776 KB |
testcase_58 | AC | 310 ms
13,572 KB |
testcase_59 | AC | 301 ms
14,544 KB |
testcase_60 | AC | 304 ms
13,228 KB |
testcase_61 | AC | 302 ms
13,648 KB |
testcase_62 | AC | 300 ms
14,032 KB |
testcase_63 | AC | 300 ms
13,348 KB |
testcase_64 | AC | 312 ms
13,260 KB |
testcase_65 | AC | 295 ms
14,036 KB |
testcase_66 | AC | 295 ms
14,728 KB |
testcase_67 | AC | 298 ms
13,572 KB |
testcase_68 | AC | 307 ms
13,964 KB |
testcase_69 | AC | 303 ms
13,104 KB |
testcase_70 | AC | 306 ms
13,696 KB |
testcase_71 | AC | 303 ms
13,244 KB |
testcase_72 | AC | 302 ms
14,476 KB |
testcase_73 | AC | 297 ms
13,984 KB |
testcase_74 | AC | 3 ms
9,948 KB |
testcase_75 | AC | 302 ms
14,312 KB |
testcase_76 | AC | 301 ms
13,884 KB |
testcase_77 | AC | 301 ms
13,272 KB |
testcase_78 | AC | 304 ms
14,108 KB |
testcase_79 | AC | 302 ms
14,820 KB |
testcase_80 | AC | 296 ms
13,496 KB |
testcase_81 | AC | 301 ms
13,628 KB |
testcase_82 | AC | 306 ms
15,240 KB |
testcase_83 | AC | 311 ms
15,056 KB |
ソースコード
#include <stdio.h> #include <stdlib.h> #define NUM_PRIME 4 long long p[NUM_PRIME] = {}; long long pow_k[200001][NUM_PRIME] = {}; void set_segt (long long t[][NUM_PRIME], int idx, long long val, int size) { int len = 1; idx = idx+size-1; for (int i = 0; i < NUM_PRIME; i++) { if (val < 0LL) { t[idx][i] = (p[i]-(val*(-1LL))%p[i])%p[i]; } else { t[idx][i] = val%p[i]; } } while (idx > 0) { idx = (idx-1)/2; for (int i = 0; i < NUM_PRIME; i++) { t[idx][i] = (t[2*idx+1][i]+pow_k[len][i]*t[2*idx+2][i])%p[i]; } len *= 2; } return; } int sum_segt_rec (long long t[][NUM_PRIME], int a, int b, int k, int l, int r, long long *ans) { long long tmp[NUM_PRIME] = {}; int len1 = 0; int len2 = 0; if (r <= a || b <= l) { for (int i = 0; i < NUM_PRIME; i++) { ans[i] = 0LL; } return 0; } if (a <= l && r <= b) { for (int i = 0; i < NUM_PRIME; i++) { ans[i] = t[k][i]; } return r-l; } len1 = sum_segt_rec(t, a, b, 2*k+1, l, (l+r)/2, ans); len2 = sum_segt_rec(t, a, b, 2*k+2, (l+r)/2, r, tmp); for (int i = 0; i < NUM_PRIME; i++) { ans[i] += tmp[i]*pow_k[len1][i]; ans[i] %= p[i]; } return len1+len2; } int sum_segt (long long t[][NUM_PRIME], int a, int b, int size, long long *ans) { return sum_segt_rec(t, a, b, 0, 0, size, ans); } int main () { int n = 0; int q = 0; long long k = 0LL; long long a = 0LL; int l = 0; int r = 0; int res = 0; long long t[262143][NUM_PRIME] = {}; int size = 1; srand(1); res = scanf("%d", &n); res = scanf("%d", &q); res = scanf("%lld", &k); for (int i = 0; i < NUM_PRIME; i++) { p[i] = (long long)(rand()%1000000000+1000000000); } for (int i = 0; i < NUM_PRIME; i++) { pow_k[0][i] = 1LL; } for (int i = 0; i < n; i++) { for (int j = 0; j < NUM_PRIME; j++) { pow_k[i+1][j] = (pow_k[i][j]*(k%p[j]))%p[j]; } } while (size <= n) { size <<= 1; } for (int i = 0; i < n; i++) { res = scanf("%lld", &a); set_segt(t, i, a, size); } while (q > 0) { long long ans[4] = {}; int is_ng = 1; res = scanf("%d", &l); res = scanf("%d", &r); res = sum_segt(t, l-1, r, size, ans); for (int i = 0; i < NUM_PRIME; i++) { if (ans[i] > 0LL) { is_ng = 0; } } if (is_ng > 0) { printf("No\n"); } else { printf("Yes\n"); } q--; } return 0; }