結果
問題 | No.2592 おでぶなおばけさん 2 |
ユーザー | null |
提出日時 | 2023-12-19 04:31:57 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 7,891 bytes |
コンパイル時間 | 10,815 ms |
コンパイル使用メモリ | 536,936 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-27 09:10:30 |
合計ジャッジ時間 | 19,709 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 24 ms
6,812 KB |
testcase_02 | AC | 28 ms
6,940 KB |
testcase_03 | AC | 12 ms
6,944 KB |
testcase_04 | AC | 11 ms
6,940 KB |
testcase_05 | AC | 50 ms
6,940 KB |
testcase_06 | AC | 32 ms
6,944 KB |
testcase_07 | AC | 36 ms
6,944 KB |
testcase_08 | AC | 41 ms
6,940 KB |
testcase_09 | AC | 14 ms
6,940 KB |
testcase_10 | AC | 15 ms
6,940 KB |
testcase_11 | AC | 41 ms
6,940 KB |
testcase_12 | AC | 10 ms
6,944 KB |
testcase_13 | AC | 72 ms
6,944 KB |
testcase_14 | AC | 72 ms
6,940 KB |
testcase_15 | AC | 54 ms
6,944 KB |
testcase_16 | AC | 73 ms
6,944 KB |
testcase_17 | AC | 77 ms
6,940 KB |
testcase_18 | AC | 56 ms
6,940 KB |
testcase_19 | AC | 45 ms
6,940 KB |
testcase_20 | AC | 35 ms
6,944 KB |
testcase_21 | AC | 28 ms
6,940 KB |
testcase_22 | AC | 39 ms
6,940 KB |
testcase_23 | AC | 78 ms
6,940 KB |
testcase_24 | AC | 67 ms
6,944 KB |
testcase_25 | AC | 37 ms
6,944 KB |
testcase_26 | AC | 40 ms
6,940 KB |
testcase_27 | AC | 97 ms
6,944 KB |
testcase_28 | AC | 111 ms
6,948 KB |
testcase_29 | AC | 101 ms
6,940 KB |
testcase_30 | AC | 96 ms
6,940 KB |
testcase_31 | AC | 137 ms
6,944 KB |
testcase_32 | AC | 97 ms
6,948 KB |
testcase_33 | AC | 99 ms
6,944 KB |
testcase_34 | AC | 112 ms
6,940 KB |
testcase_35 | AC | 96 ms
6,944 KB |
testcase_36 | AC | 98 ms
6,940 KB |
testcase_37 | AC | 113 ms
6,940 KB |
testcase_38 | AC | 94 ms
6,944 KB |
testcase_39 | AC | 96 ms
6,944 KB |
testcase_40 | AC | 97 ms
6,940 KB |
testcase_41 | AC | 97 ms
6,944 KB |
testcase_42 | AC | 93 ms
6,944 KB |
testcase_43 | AC | 95 ms
6,940 KB |
testcase_44 | AC | 96 ms
6,944 KB |
testcase_45 | AC | 115 ms
6,944 KB |
testcase_46 | AC | 94 ms
6,944 KB |
testcase_47 | WA | - |
testcase_48 | AC | 70 ms
6,940 KB |
testcase_49 | AC | 72 ms
6,940 KB |
testcase_50 | AC | 69 ms
6,944 KB |
testcase_51 | AC | 69 ms
6,944 KB |
testcase_52 | AC | 96 ms
6,940 KB |
testcase_53 | AC | 96 ms
6,944 KB |
testcase_54 | AC | 94 ms
6,940 KB |
testcase_55 | AC | 99 ms
6,944 KB |
testcase_56 | AC | 98 ms
6,944 KB |
testcase_57 | AC | 46 ms
6,944 KB |
testcase_58 | AC | 96 ms
6,944 KB |
testcase_59 | AC | 96 ms
6,940 KB |
testcase_60 | AC | 100 ms
6,940 KB |
testcase_61 | AC | 95 ms
6,944 KB |
testcase_62 | AC | 97 ms
6,940 KB |
testcase_63 | AC | 89 ms
6,944 KB |
testcase_64 | AC | 94 ms
6,940 KB |
testcase_65 | AC | 85 ms
6,944 KB |
testcase_66 | WA | - |
testcase_67 | AC | 84 ms
6,940 KB |
testcase_68 | AC | 89 ms
6,940 KB |
testcase_69 | AC | 83 ms
6,940 KB |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | AC | 85 ms
6,944 KB |
testcase_73 | AC | 85 ms
6,940 KB |
testcase_74 | AC | 2 ms
6,940 KB |
testcase_75 | AC | 91 ms
6,940 KB |
testcase_76 | AC | 94 ms
6,940 KB |
testcase_77 | AC | 93 ms
6,940 KB |
testcase_78 | AC | 91 ms
6,940 KB |
testcase_79 | AC | 94 ms
6,944 KB |
testcase_80 | AC | 98 ms
6,940 KB |
testcase_81 | AC | 94 ms
6,940 KB |
testcase_82 | AC | 92 ms
6,940 KB |
testcase_83 | AC | 92 ms
6,940 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(1e9, 3e9); int main() { int n, q; ll k; scanf("%d%d", &n, &q); cin >> k; vector<ll> a(n); rep(i, n)cin >> a[i]; vector<ll> rnd(1); rep(i, 1) { ll x = dist(engine); while (not is_prime(x))x = dist(engine); rnd[i] = x; } vector<vector<ll>> cs; rep(i, 1) { ll kk = rnd[i]; ll x = 1; x %= kk; vector<ll> b(n); rep(j, n) { b[j] = (a[j] % kk) * x; b[j] %= kk; x *= k; x %= kk; } vector<ll> 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) { ll x = cs[j][r] - cs[j][l]; x += rnd[j]; x %= rnd[j]; if (x != 0) { ans = 1; break; } } printyn(ans); } Please AC; }