結果
問題 | No.2592 おでぶなおばけさん 2 |
ユーザー | null |
提出日時 | 2023-12-19 02:32:09 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,639 ms / 2,500 ms |
コード長 | 7,955 bytes |
コンパイル時間 | 9,608 ms |
コンパイル使用メモリ | 551,552 KB |
実行使用メモリ | 325,504 KB |
最終ジャッジ日時 | 2024-09-27 09:35:27 |
合計ジャッジ時間 | 111,387 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
6,812 KB |
testcase_01 | AC | 647 ms
144,256 KB |
testcase_02 | AC | 485 ms
108,236 KB |
testcase_03 | AC | 180 ms
41,312 KB |
testcase_04 | AC | 112 ms
25,872 KB |
testcase_05 | AC | 1,400 ms
316,512 KB |
testcase_06 | AC | 588 ms
116,588 KB |
testcase_07 | AC | 622 ms
110,324 KB |
testcase_08 | AC | 821 ms
173,896 KB |
testcase_09 | AC | 265 ms
56,804 KB |
testcase_10 | AC | 115 ms
15,872 KB |
testcase_11 | AC | 848 ms
179,116 KB |
testcase_12 | AC | 166 ms
36,832 KB |
testcase_13 | AC | 940 ms
203,924 KB |
testcase_14 | AC | 946 ms
207,104 KB |
testcase_15 | AC | 623 ms
132,908 KB |
testcase_16 | AC | 973 ms
205,668 KB |
testcase_17 | AC | 1,119 ms
243,224 KB |
testcase_18 | AC | 627 ms
135,120 KB |
testcase_19 | AC | 419 ms
90,608 KB |
testcase_20 | AC | 1,335 ms
140,736 KB |
testcase_21 | AC | 1,042 ms
79,388 KB |
testcase_22 | AC | 1,639 ms
217,996 KB |
testcase_23 | AC | 1,023 ms
246,156 KB |
testcase_24 | AC | 724 ms
168,536 KB |
testcase_25 | AC | 280 ms
63,328 KB |
testcase_26 | AC | 283 ms
65,680 KB |
testcase_27 | AC | 1,349 ms
325,420 KB |
testcase_28 | AC | 1,336 ms
325,332 KB |
testcase_29 | AC | 1,309 ms
325,292 KB |
testcase_30 | AC | 1,332 ms
325,372 KB |
testcase_31 | AC | 1,518 ms
325,392 KB |
testcase_32 | AC | 1,442 ms
325,404 KB |
testcase_33 | AC | 1,512 ms
325,220 KB |
testcase_34 | AC | 1,599 ms
325,292 KB |
testcase_35 | AC | 1,603 ms
325,476 KB |
testcase_36 | AC | 1,456 ms
325,360 KB |
testcase_37 | AC | 1,495 ms
325,424 KB |
testcase_38 | AC | 1,481 ms
325,364 KB |
testcase_39 | AC | 1,503 ms
325,408 KB |
testcase_40 | AC | 1,430 ms
325,352 KB |
testcase_41 | AC | 1,536 ms
325,340 KB |
testcase_42 | AC | 1,467 ms
325,376 KB |
testcase_43 | AC | 1,409 ms
325,188 KB |
testcase_44 | AC | 1,484 ms
325,196 KB |
testcase_45 | AC | 1,436 ms
325,312 KB |
testcase_46 | AC | 1,471 ms
325,384 KB |
testcase_47 | AC | 1,215 ms
325,316 KB |
testcase_48 | AC | 1,306 ms
325,204 KB |
testcase_49 | AC | 1,188 ms
325,320 KB |
testcase_50 | AC | 1,174 ms
325,380 KB |
testcase_51 | AC | 1,193 ms
325,376 KB |
testcase_52 | AC | 1,518 ms
325,292 KB |
testcase_53 | AC | 1,506 ms
325,308 KB |
testcase_54 | AC | 1,448 ms
325,324 KB |
testcase_55 | AC | 1,462 ms
325,180 KB |
testcase_56 | AC | 1,428 ms
325,316 KB |
testcase_57 | AC | 1,139 ms
325,324 KB |
testcase_58 | AC | 1,327 ms
325,380 KB |
testcase_59 | AC | 1,345 ms
325,340 KB |
testcase_60 | AC | 1,308 ms
325,372 KB |
testcase_61 | AC | 1,301 ms
325,264 KB |
testcase_62 | AC | 1,348 ms
325,316 KB |
testcase_63 | AC | 1,329 ms
325,316 KB |
testcase_64 | AC | 1,467 ms
325,384 KB |
testcase_65 | AC | 1,294 ms
325,336 KB |
testcase_66 | AC | 1,336 ms
325,504 KB |
testcase_67 | AC | 1,322 ms
325,412 KB |
testcase_68 | AC | 1,348 ms
325,384 KB |
testcase_69 | AC | 1,363 ms
325,408 KB |
testcase_70 | AC | 1,332 ms
325,336 KB |
testcase_71 | AC | 1,319 ms
325,308 KB |
testcase_72 | AC | 1,336 ms
325,400 KB |
testcase_73 | AC | 1,365 ms
325,312 KB |
testcase_74 | AC | 4 ms
6,940 KB |
testcase_75 | AC | 1,484 ms
325,360 KB |
testcase_76 | AC | 1,432 ms
325,320 KB |
testcase_77 | AC | 1,451 ms
325,296 KB |
testcase_78 | AC | 1,456 ms
325,396 KB |
testcase_79 | AC | 1,435 ms
325,380 KB |
testcase_80 | AC | 1,435 ms
325,392 KB |
testcase_81 | AC | 1,484 ms
325,420 KB |
testcase_82 | AC | 1,457 ms
325,388 KB |
testcase_83 | AC | 1,441 ms
325,328 KB |
ソースコード
/* このコード、と~おれ! Be accepted! ∧_∧ (。・ω・。)つ━☆・*。 ⊂ ノ ・゜+. しーJ °。+ *´¨) .· ´¸.·*´¨) ¸.·*¨) (¸.·´ (¸.·'* ☆ */ #include <cstdio> #include <algorithm> #include <string> #include <cmath> #include <cstring> #include <vector> #include <numeric> #include <iostream> #include <random> #include <map> #include <unordered_map> #include <queue> #include <regex> #include <functional> #include <complex> #include <list> #include <cassert> #include <iomanip> #include <set> #include <stack> #include <bitset> #include <array> #include <chrono> #include <unordered_set> //#pragma GCC target("arch=skylake-avx512") //#pragma GCC target("avx2") //#pragma GCC optimize("O3") #pragma GCC optimize("Ofast") //#pragma GCC target("sse4") #pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define repeat(i, n, m) for(int i = n; i < (m); ++i) #define rep(i, n) for(int i = 0; i < (n); ++i) #define printynl(a) printf(a ? "yes\n" : "no\n") #define printyn(a) printf(a ? "Yes\n" : "No\n") #define printYN(a) printf(a ? "YES\n" : "NO\n") #define printim(a) printf(a ? "possible\n" : "imposible\n") #define printdb(a) printf("%.50lf\n", a) #define printLdb(a) printf("%.50Lf\n", a) #define printdbd(a) printf("%.16lf\n", a) #define prints(s) printf("%s\n", s.c_str()) #define all(x) (x).begin(), (x).end() #define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI) #define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L) #define Please return #define AC 0 #define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) using ll = long long; using ull = unsigned long long; constexpr int INF = 1073741823; constexpr int MINF = -1073741823; constexpr ll LINF = ll(4661686018427387903); constexpr ll MOD = 1e9 + 7; constexpr ll mod = 998244353; constexpr long double eps = 1e-14; const long double PI = acosl(-1.0L); using namespace std; void scans(string& str) { char c; str = ""; scanf("%c", &c); if (c == '\n')scanf("%c", &c); while (c != '\n' && c != -1 && c != ' ') { str += c; scanf("%c", &c); } } void scanc(char& str) { char c; scanf("%c", &c); if (c == -1)return; while (c == '\n') { scanf("%c", &c); } str = c; } double acot(double x) { return PI / 2 - atan(x); } ll LSB(ll n) { return (n & (-n)); } template<typename T> inline T chmin(T& a, const T& b) { if (a > b)a = b; return a; } template<typename T> inline T chmax(T& a, const T& b) { if (a < b)a = b; return a; } //cpp_int #if __has_include(<boost/multiprecision/cpp_int.hpp>) #include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_dec_float.hpp> using namespace boost::multiprecision; #else using cpp_int = ll; #endif //atcoder library #if __has_include(<atcoder/all>) #include <atcoder/all> //using namespace atcoder; #endif /* random_device seed_gen; mt19937 engine(seed_gen()); uniform_int_distribution dist(1, 100); */ /*----------------------------------------------------------------------------------*/ // montgomery modint (MOD < 2^62, MOD is odd) struct MontgomeryModInt64 { using mint = MontgomeryModInt64; using u64 = uint64_t; using u128 = __uint128_t; // static menber static u64 MOD; static u64 INV_MOD; // INV_MOD * MOD ≡ 1 (mod 2^64) static u64 T128; // 2^128 (mod MOD) // inner value u64 val; // constructor MontgomeryModInt64() : val(0) { } MontgomeryModInt64(long long v) : val(reduce((u128(v) + MOD)* T128)) { } u64 get() const { u64 res = reduce(val); return res >= MOD ? res - MOD : res; } // mod getter and setter static u64 get_mod() { return MOD; } static void set_mod(u64 mod) { assert(mod < (1LL << 62)); assert((mod & 1)); MOD = mod; T128 = -u128(mod) % mod; INV_MOD = get_inv_mod(); } static u64 get_inv_mod() { u64 res = MOD; for (int i = 0; i < 5; ++i) res *= 2 - MOD * res; return res; } static u64 reduce(const u128& v) { return (v + u128(u64(v) * u64(-INV_MOD)) * MOD) >> 64; } // arithmetic operators mint operator - () const { return mint() - mint(*this); } mint operator + (const mint& r) const { return mint(*this) += r; } mint operator - (const mint& r) const { return mint(*this) -= r; } mint operator * (const mint& r) const { return mint(*this) *= r; } mint operator / (const mint& r) const { return mint(*this) /= r; } mint& operator += (const mint& r) { if ((val += r.val) >= 2 * MOD) val -= 2 * MOD; return *this; } mint& operator -= (const mint& r) { if ((val += 2 * MOD - r.val) >= 2 * MOD) val -= 2 * MOD; return *this; } mint& operator *= (const mint& r) { val = reduce(u128(val) * r.val); return *this; } mint& operator /= (const mint& r) { *this *= r.inv(); return *this; } mint inv() const { return pow(MOD - 2); } mint pow(u128 n) const { mint res(1), mul(*this); while (n > 0) { if (n & 1) res *= mul; mul *= mul; n >>= 1; } return res; } // other operators bool operator == (const mint& r) const { return (val >= MOD ? val - MOD : val) == (r.val >= MOD ? r.val - MOD : r.val); } bool operator != (const mint& r) const { return (val >= MOD ? val - MOD : val) != (r.val >= MOD ? r.val - MOD : r.val); } friend istream& operator >> (istream& is, mint& x) { long long t; is >> t; x = mint(t); return is; } friend ostream& operator << (ostream& os, const mint& x) { return os << x.get(); } friend mint modpow(const mint& r, long long n) { return r.pow(n); } friend mint modinv(const mint& r) { return r.inv(); } }; typename MontgomeryModInt64::u64 MontgomeryModInt64::MOD, MontgomeryModInt64::INV_MOD, MontgomeryModInt64::T128; // Miller-Rabin bool MillerRabin(long long N, vector<long long> A) { using mint = MontgomeryModInt64; mint::set_mod(N); long long s = 0, d = N - 1; while (d % 2 == 0) { ++s; d >>= 1; } for (auto a : A) { if (N <= a) return true; mint x = mint(a).pow(d); if (x != 1) { long long t; for (t = 0; t < s; ++t) { if (x == N - 1) break; x *= x; } if (t == s) return false; } } return true; } bool is_prime(long long N) { if (N <= 1) return false; else if (N == 2) return true; else if (N % 2 == 0) return false; else if (N < 4759123141LL) return MillerRabin(N, { 2, 7, 61 }); else return MillerRabin(N, { 2, 325, 9375, 28178, 450775, 9780504, 1795265022 }); } //https://drken1215.hatenablog.com/entry/2023/05/23/233000 random_device seed_gen; mt19937 engine(seed_gen()); uniform_int_distribution<ll> dist(1e18, 3e18); int main() { int n, q; int128_t k; scanf("%d%d", &n, &q); cin >> k; vector<int128_t> a(n); rep(i, n)cin >> a[i]; vector<int128_t> rnd(100); rep(i, 100) { ll x = dist(engine); while (not is_prime(x))x = dist(engine); rnd[i] = x; } vector<vector<int128_t>> cs; rep(i, 100) { int128_t kk = rnd[i]; int128_t x = 1; x %= kk; vector<int128_t> b(n); rep(j, n) { b[j] = (a[j] % kk) * x; b[j] %= kk; x *= k; x %= kk; } vector<int128_t> c(n + 1); rep(j, n) { c[j + 1] = c[j] + b[j]; c[j + 1] %= kk; } cs.push_back(c); } rep(i, q) { int l, r; scanf("%d%d", &l, &r); --l; int ans = 0; rep(j, 100) { int128_t x = cs[j][r] - cs[j][l]; x += rnd[j]; x %= rnd[j]; if (x != 0) { ans = 1; break; } } printyn(ans); } Please AC; }