結果
問題 | No.2592 おでぶなおばけさん 2 |
ユーザー | 👑 hos.lyric |
提出日時 | 2023-12-20 00:25:12 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 180 ms / 2,500 ms |
コード長 | 3,432 bytes |
コンパイル時間 | 1,501 ms |
コンパイル使用メモリ | 122,936 KB |
実行使用メモリ | 21,516 KB |
最終ジャッジ日時 | 2024-09-27 09:31:32 |
合計ジャッジ時間 | 18,810 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 34 ms
11,056 KB |
testcase_02 | AC | 49 ms
9,228 KB |
testcase_03 | AC | 19 ms
6,940 KB |
testcase_04 | AC | 18 ms
6,940 KB |
testcase_05 | AC | 87 ms
20,272 KB |
testcase_06 | AC | 51 ms
9,812 KB |
testcase_07 | AC | 61 ms
9,696 KB |
testcase_08 | AC | 63 ms
12,832 KB |
testcase_09 | AC | 20 ms
6,944 KB |
testcase_10 | AC | 22 ms
6,944 KB |
testcase_11 | AC | 64 ms
13,084 KB |
testcase_12 | AC | 13 ms
6,944 KB |
testcase_13 | AC | 129 ms
14,928 KB |
testcase_14 | AC | 134 ms
15,144 KB |
testcase_15 | AC | 94 ms
11,116 KB |
testcase_16 | AC | 137 ms
14,972 KB |
testcase_17 | AC | 149 ms
17,008 KB |
testcase_18 | AC | 97 ms
11,156 KB |
testcase_19 | AC | 77 ms
8,944 KB |
testcase_20 | AC | 91 ms
11,592 KB |
testcase_21 | AC | 69 ms
8,176 KB |
testcase_22 | AC | 121 ms
15,708 KB |
testcase_23 | AC | 149 ms
17,220 KB |
testcase_24 | AC | 110 ms
13,104 KB |
testcase_25 | AC | 65 ms
7,424 KB |
testcase_26 | AC | 65 ms
7,552 KB |
testcase_27 | AC | 167 ms
21,512 KB |
testcase_28 | AC | 168 ms
21,512 KB |
testcase_29 | AC | 168 ms
21,508 KB |
testcase_30 | AC | 162 ms
21,508 KB |
testcase_31 | AC | 168 ms
21,384 KB |
testcase_32 | AC | 170 ms
21,512 KB |
testcase_33 | AC | 171 ms
21,508 KB |
testcase_34 | AC | 169 ms
21,384 KB |
testcase_35 | AC | 172 ms
21,388 KB |
testcase_36 | AC | 170 ms
21,508 KB |
testcase_37 | AC | 171 ms
21,508 KB |
testcase_38 | AC | 169 ms
21,388 KB |
testcase_39 | AC | 172 ms
21,508 KB |
testcase_40 | AC | 172 ms
21,508 KB |
testcase_41 | AC | 173 ms
21,512 KB |
testcase_42 | AC | 168 ms
21,284 KB |
testcase_43 | AC | 168 ms
21,516 KB |
testcase_44 | AC | 168 ms
21,380 KB |
testcase_45 | AC | 170 ms
21,512 KB |
testcase_46 | AC | 170 ms
21,384 KB |
testcase_47 | AC | 165 ms
21,508 KB |
testcase_48 | AC | 163 ms
21,384 KB |
testcase_49 | AC | 164 ms
21,512 KB |
testcase_50 | AC | 164 ms
21,512 KB |
testcase_51 | AC | 164 ms
21,508 KB |
testcase_52 | AC | 174 ms
21,512 KB |
testcase_53 | AC | 172 ms
21,512 KB |
testcase_54 | AC | 168 ms
21,516 KB |
testcase_55 | AC | 171 ms
21,508 KB |
testcase_56 | AC | 173 ms
21,512 KB |
testcase_57 | AC | 64 ms
20,600 KB |
testcase_58 | AC | 172 ms
21,512 KB |
testcase_59 | AC | 170 ms
21,348 KB |
testcase_60 | AC | 172 ms
21,388 KB |
testcase_61 | AC | 172 ms
21,512 KB |
testcase_62 | AC | 172 ms
21,512 KB |
testcase_63 | AC | 170 ms
21,284 KB |
testcase_64 | AC | 175 ms
21,384 KB |
testcase_65 | AC | 170 ms
21,504 KB |
testcase_66 | AC | 163 ms
21,512 KB |
testcase_67 | AC | 168 ms
21,388 KB |
testcase_68 | AC | 168 ms
21,508 KB |
testcase_69 | AC | 165 ms
21,508 KB |
testcase_70 | AC | 168 ms
21,516 KB |
testcase_71 | AC | 165 ms
21,512 KB |
testcase_72 | AC | 168 ms
21,384 KB |
testcase_73 | AC | 168 ms
21,512 KB |
testcase_74 | AC | 2 ms
6,940 KB |
testcase_75 | AC | 172 ms
21,388 KB |
testcase_76 | AC | 171 ms
21,384 KB |
testcase_77 | AC | 170 ms
21,380 KB |
testcase_78 | AC | 171 ms
21,384 KB |
testcase_79 | AC | 180 ms
21,380 KB |
testcase_80 | AC | 171 ms
21,508 KB |
testcase_81 | AC | 170 ms
21,512 KB |
testcase_82 | AC | 172 ms
21,508 KB |
testcase_83 | AC | 168 ms
21,508 KB |
ソースコード
#include <cassert> #include <cmath> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <functional> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #include <chrono> using namespace std; using Int = long long; template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; }; template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; } template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; } template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; } template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; } #define COLOR(s) ("\x1b[" s "m") template<class T> T power(T a, Int e, T m) { T b = 1; for (; e; e >>= 1) { if (e & 1) b = (b * a) % m; a = (a * a) % m; } return b; } // Checks if n is a prime using Miller-Rabin test bool isPrime(Int n) { if (n <= 1 || n % 2 == 0) return (n == 2); const int s = __builtin_ctzll(n - 1); const Int d = (n - 1) >> s; // http://miller-rabin.appspot.com/ for (const Int base : {2, 325, 9375, 28178, 450775, 9780504, 1795265022}) { __int128 a = base % n; if (a == 0) continue; a = power<__int128>(a, d, n); if (a == 1 || a == n - 1) continue; bool ok = false; for (int i = 0; i < s - 1; ++i) { a = (a * a) % n; if (a == n - 1) { ok = true; break; } } if (!ok) return false; } return true; } #ifdef LOCAL mt19937_64 rng(58); #else mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); #endif // [l, r] Int randLong(Int l, Int r) { return uniform_int_distribution<Int>(l, r)(rng); } constexpr int H = 10; Int M[H]; int N, Q; Int K; vector<Int> A; vector<int> L, R; int main() { for (int h = 0; h < H; ++h) { for (; ; ) { M[h] = randLong(1LL << 30, 1LL << 31); if (isPrime(M[h])) { break; } } } cerr<<"M = ";pv(M,M+H); for (; ~scanf("%d%d%lld", &N, &Q, &K); ) { A.resize(N); for (int i = 0; i < N; ++i) { scanf("%lld", &A[i]); } L.resize(Q); R.resize(Q); for (int q = 0; q < Q; ++q) { scanf("%d%d", &L[q], &R[q]); --L[q]; } vector<vector<Int>> KK(H, vector<Int>(N + 1)); vector<vector<Int>> fss(H, vector<Int>(N + 1, 0)); for (int h = 0; h < H; ++h) { const Int k = K % M[h]; KK[h][0] = 1; for (int i = 1; i <= N; ++i) { KK[h][i] = (KK[h][i - 1] * k) % M[h]; } for (int i = N; --i >= 0; ) { fss[h][i] = (A[i] + k * fss[h][i + 1]) % M[h]; } } for (int q = 0; q < Q; ++q) { bool ans = false; for (int h = 0; h < H; ++h) { Int f = (fss[h][L[q]] - KK[h][R[q] - L[q]] * fss[h][R[q]]) % M[h]; ans = ans || f; } puts(ans ? "Yes" : "No"); } } return 0; }