結果
問題 | No.2592 おでぶなおばけさん 2 |
ユーザー | null |
提出日時 | 2023-12-19 04:33:22 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 140 ms / 2,500 ms |
コード長 | 7,947 bytes |
コンパイル時間 | 9,404 ms |
コンパイル使用メモリ | 551,948 KB |
実行使用メモリ | 16,016 KB |
最終ジャッジ日時 | 2024-09-27 09:28:31 |
合計ジャッジ時間 | 21,203 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 28 ms
8,960 KB |
testcase_02 | AC | 31 ms
7,552 KB |
testcase_03 | AC | 13 ms
6,940 KB |
testcase_04 | AC | 13 ms
6,940 KB |
testcase_05 | AC | 60 ms
15,480 KB |
testcase_06 | AC | 35 ms
7,808 KB |
testcase_07 | AC | 38 ms
7,552 KB |
testcase_08 | AC | 42 ms
9,984 KB |
testcase_09 | AC | 15 ms
6,944 KB |
testcase_10 | AC | 16 ms
6,944 KB |
testcase_11 | AC | 43 ms
10,240 KB |
testcase_12 | AC | 11 ms
6,944 KB |
testcase_13 | AC | 75 ms
11,264 KB |
testcase_14 | AC | 75 ms
11,264 KB |
testcase_15 | AC | 57 ms
8,448 KB |
testcase_16 | AC | 74 ms
11,264 KB |
testcase_17 | AC | 86 ms
12,672 KB |
testcase_18 | AC | 58 ms
8,576 KB |
testcase_19 | AC | 48 ms
6,940 KB |
testcase_20 | AC | 38 ms
8,704 KB |
testcase_21 | AC | 32 ms
6,944 KB |
testcase_22 | AC | 44 ms
11,648 KB |
testcase_23 | AC | 82 ms
12,800 KB |
testcase_24 | AC | 64 ms
9,856 KB |
testcase_25 | AC | 39 ms
6,944 KB |
testcase_26 | AC | 41 ms
6,944 KB |
testcase_27 | AC | 98 ms
15,956 KB |
testcase_28 | AC | 99 ms
15,984 KB |
testcase_29 | AC | 105 ms
15,852 KB |
testcase_30 | AC | 103 ms
15,928 KB |
testcase_31 | AC | 136 ms
15,916 KB |
testcase_32 | AC | 119 ms
15,844 KB |
testcase_33 | AC | 107 ms
15,828 KB |
testcase_34 | AC | 135 ms
15,844 KB |
testcase_35 | AC | 140 ms
15,836 KB |
testcase_36 | AC | 104 ms
15,944 KB |
testcase_37 | AC | 102 ms
15,844 KB |
testcase_38 | AC | 119 ms
15,796 KB |
testcase_39 | AC | 126 ms
15,952 KB |
testcase_40 | AC | 101 ms
15,860 KB |
testcase_41 | AC | 101 ms
16,016 KB |
testcase_42 | AC | 99 ms
15,996 KB |
testcase_43 | AC | 101 ms
16,000 KB |
testcase_44 | AC | 100 ms
15,920 KB |
testcase_45 | AC | 106 ms
16,000 KB |
testcase_46 | AC | 106 ms
15,844 KB |
testcase_47 | AC | 78 ms
15,932 KB |
testcase_48 | AC | 82 ms
15,840 KB |
testcase_49 | AC | 78 ms
16,012 KB |
testcase_50 | AC | 81 ms
15,796 KB |
testcase_51 | AC | 81 ms
15,904 KB |
testcase_52 | AC | 102 ms
15,856 KB |
testcase_53 | AC | 99 ms
15,836 KB |
testcase_54 | AC | 103 ms
15,844 KB |
testcase_55 | AC | 103 ms
15,992 KB |
testcase_56 | AC | 99 ms
15,840 KB |
testcase_57 | AC | 48 ms
15,996 KB |
testcase_58 | AC | 100 ms
15,908 KB |
testcase_59 | AC | 101 ms
15,916 KB |
testcase_60 | AC | 100 ms
15,916 KB |
testcase_61 | AC | 97 ms
15,900 KB |
testcase_62 | AC | 96 ms
16,004 KB |
testcase_63 | AC | 95 ms
15,840 KB |
testcase_64 | AC | 98 ms
15,952 KB |
testcase_65 | AC | 92 ms
15,836 KB |
testcase_66 | AC | 91 ms
15,944 KB |
testcase_67 | AC | 90 ms
15,932 KB |
testcase_68 | AC | 91 ms
15,896 KB |
testcase_69 | AC | 87 ms
15,824 KB |
testcase_70 | AC | 90 ms
15,840 KB |
testcase_71 | AC | 93 ms
15,904 KB |
testcase_72 | AC | 93 ms
15,992 KB |
testcase_73 | AC | 95 ms
15,716 KB |
testcase_74 | AC | 2 ms
6,944 KB |
testcase_75 | AC | 103 ms
16,012 KB |
testcase_76 | AC | 100 ms
15,988 KB |
testcase_77 | AC | 103 ms
15,988 KB |
testcase_78 | AC | 108 ms
15,928 KB |
testcase_79 | AC | 107 ms
15,912 KB |
testcase_80 | AC | 102 ms
15,932 KB |
testcase_81 | AC | 100 ms
15,980 KB |
testcase_82 | AC | 102 ms
15,848 KB |
testcase_83 | AC | 99 ms
15,944 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(1); rep(i, 1) { ll x = dist(engine); while (not is_prime(x))x = dist(engine); rnd[i] = x; } vector<vector<int128_t>> cs; rep(i, 1) { 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, 1) { 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; }