結果
問題 | No.2592 おでぶなおばけさん 2 |
ユーザー | t98slider |
提出日時 | 2023-12-21 01:51:54 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,068 bytes |
コンパイル時間 | 2,537 ms |
コンパイル使用メモリ | 213,916 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-27 10:36:25 |
合計ジャッジ時間 | 175,891 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,971 ms
6,812 KB |
testcase_01 | AC | 1,973 ms
6,812 KB |
testcase_02 | AC | 1,972 ms
6,940 KB |
testcase_03 | AC | 1,971 ms
6,944 KB |
testcase_04 | AC | 1,972 ms
6,944 KB |
testcase_05 | AC | 1,972 ms
6,944 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 1,979 ms
6,944 KB |
testcase_14 | AC | 1,975 ms
6,940 KB |
testcase_15 | AC | 1,975 ms
6,944 KB |
testcase_16 | AC | 1,978 ms
6,940 KB |
testcase_17 | AC | 1,975 ms
6,944 KB |
testcase_18 | AC | 1,975 ms
6,940 KB |
testcase_19 | AC | 1,975 ms
6,940 KB |
testcase_20 | AC | 1,976 ms
6,944 KB |
testcase_21 | AC | 1,976 ms
6,940 KB |
testcase_22 | AC | 1,976 ms
6,940 KB |
testcase_23 | AC | 1,975 ms
6,940 KB |
testcase_24 | AC | 1,975 ms
6,940 KB |
testcase_25 | AC | 1,973 ms
6,940 KB |
testcase_26 | AC | 1,974 ms
6,940 KB |
testcase_27 | AC | 1,985 ms
6,940 KB |
testcase_28 | AC | 1,976 ms
6,940 KB |
testcase_29 | AC | 1,974 ms
6,940 KB |
testcase_30 | AC | 1,976 ms
6,944 KB |
testcase_31 | AC | 1,975 ms
6,944 KB |
testcase_32 | AC | 1,976 ms
6,940 KB |
testcase_33 | AC | 1,976 ms
6,944 KB |
testcase_34 | AC | 1,976 ms
6,944 KB |
testcase_35 | AC | 1,975 ms
6,944 KB |
testcase_36 | AC | 1,976 ms
6,940 KB |
testcase_37 | AC | 1,976 ms
6,940 KB |
testcase_38 | AC | 1,974 ms
6,944 KB |
testcase_39 | AC | 1,978 ms
6,940 KB |
testcase_40 | AC | 1,976 ms
6,940 KB |
testcase_41 | AC | 1,976 ms
6,944 KB |
testcase_42 | AC | 1,989 ms
6,940 KB |
testcase_43 | AC | 1,977 ms
6,940 KB |
testcase_44 | AC | 1,976 ms
6,944 KB |
testcase_45 | AC | 1,975 ms
6,940 KB |
testcase_46 | AC | 1,978 ms
6,944 KB |
testcase_47 | AC | 1,976 ms
6,944 KB |
testcase_48 | AC | 1,974 ms
6,944 KB |
testcase_49 | AC | 1,976 ms
6,940 KB |
testcase_50 | AC | 1,975 ms
6,944 KB |
testcase_51 | AC | 1,975 ms
6,940 KB |
testcase_52 | AC | 1,975 ms
6,940 KB |
testcase_53 | AC | 1,977 ms
6,940 KB |
testcase_54 | AC | 1,977 ms
6,940 KB |
testcase_55 | AC | 1,976 ms
6,944 KB |
testcase_56 | AC | 1,978 ms
6,944 KB |
testcase_57 | AC | 1,982 ms
6,944 KB |
testcase_58 | AC | 1,975 ms
6,940 KB |
testcase_59 | AC | 1,977 ms
6,944 KB |
testcase_60 | AC | 1,977 ms
6,944 KB |
testcase_61 | AC | 1,976 ms
6,940 KB |
testcase_62 | AC | 1,978 ms
6,940 KB |
testcase_63 | AC | 1,974 ms
6,940 KB |
testcase_64 | AC | 1,976 ms
6,944 KB |
testcase_65 | AC | 1,976 ms
6,940 KB |
testcase_66 | AC | 1,978 ms
6,940 KB |
testcase_67 | AC | 1,981 ms
6,940 KB |
testcase_68 | AC | 1,977 ms
6,944 KB |
testcase_69 | AC | 1,978 ms
6,944 KB |
testcase_70 | AC | 1,976 ms
6,944 KB |
testcase_71 | AC | 1,974 ms
6,944 KB |
testcase_72 | AC | 1,983 ms
6,940 KB |
testcase_73 | AC | 1,983 ms
6,940 KB |
testcase_74 | AC | 1,970 ms
6,940 KB |
testcase_75 | AC | 1,977 ms
6,940 KB |
testcase_76 | AC | 1,978 ms
6,940 KB |
testcase_77 | AC | 1,976 ms
6,940 KB |
testcase_78 | AC | 1,975 ms
6,940 KB |
testcase_79 | AC | 1,979 ms
6,944 KB |
testcase_80 | AC | 1,975 ms
6,940 KB |
testcase_81 | AC | 1,976 ms
6,940 KB |
testcase_82 | AC | 1,975 ms
6,940 KB |
testcase_83 | AC | 1,976 ms
6,940 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; unsigned long long xor64() { static unsigned long long x = (unsigned long long)(chrono::duration_cast<chrono::nanoseconds>( chrono::high_resolution_clock::now().time_since_epoch()).count()) * 10150724397891781847ULL; x ^= x << 7; return x ^= x >> 9; } struct Miller_Rabin { unsigned long long mul_mod(unsigned long long a, unsigned long long b, unsigned long long m) { unsigned long long ans = 0; #ifdef LOCAL if(a > b) std::swap(a, b); while(b){ if(b & 1){ ans += a; if(ans >= m) ans -= m; } if((a <<= 1) >= m) a -= m; b >>= 1; } #else ans = (unsigned long long)((__int128)(a) * (__int128)(b) % m); #endif return ans; } unsigned long long pow_mod(unsigned long long x, unsigned long long n, unsigned long long m) { if (m == 1) return 0; unsigned long long r = 1; unsigned long long y = x % m; while (n) { if (n & 1) r = mul_mod(r, y, m); y = mul_mod(y, y, m); n >>= 1; } return r; } bool is_prime(unsigned long long n) { if (n <= 1) return false; if (n == 2) return true; if (n % 2 == 0) return false; unsigned long long d = n - 1; while (d % 2 == 0) d /= 2; static std::vector<std::vector<long long>> bases = {{2, 6, 61}, {2, 325, 9375, 28178, 450775, 9780504, 1795265022}}; for (long long a : bases[d > 4759123141]) { unsigned long long t = d; unsigned long long y = pow_mod(a, t, n); if(a % n){ while (t != n - 1 && y != 1 && y != n - 1) { y = mul_mod(y, y, n); t <<= 1; } } if (y != n - 1 && t % 2 == 0) return false; } return true; } }; int main(){ ios::sync_with_stdio(false); cin.tie(0); clock_t finish = clock() + CLOCKS_PER_SEC / 1000 * 1960; ll n, q, k; cin >> n >> q >> k; vector<ll> a(n); vector<int> s(n + 1); vector<pair<int,int>> query(q); vector<bool> ans(q); Miller_Rabin MR; for(auto &&v : a) cin >> v; for(auto &&[l, r] : query) cin >> l >> r, l--; while(clock() <= finish){ int mod = xor64() & 2147483647; while(!MR.is_prime(mod)) mod = xor64() & 2147483647; auto safe = [&](long long v){ v %= mod; if(v < 0) v += mod; return v; }; int d = 1; for(int i = 0; i < n; i++){ s[i + 1] = safe(s[i] + a[i] * d); d = safe(d * k); } for(int i = 0; i < q; i++){ if(ans[i]) continue; auto [l, r] = query[i]; ans[i] = s[r] != s[l]; } } for(auto &&flg : ans) cout << (flg ? "Yes" : "No") << '\n'; }