結果
| 問題 |
No.2592 おでぶなおばけさん 2
|
| コンテスト | |
| ユーザー |
Misuki
|
| 提出日時 | 2024-02-08 22:01:29 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 5,251 bytes |
| コンパイル時間 | 3,038 ms |
| コンパイル使用メモリ | 213,804 KB |
| 実行使用メモリ | 816,416 KB |
| 最終ジャッジ日時 | 2024-09-28 12:52:25 |
| 合計ジャッジ時間 | 12,866 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | MLE * 1 |
| other | -- * 83 |
ソースコード
#pragma GCC optimize("O2")
#include <algorithm>
#include <array>
#include <bit>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfenv>
#include <cfloat>
#include <chrono>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <compare>
#include <complex>
#include <concepts>
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numbers>
#include <numeric>
#include <ostream>
#include <queue>
#include <random>
#include <ranges>
#include <set>
#include <span>
#include <sstream>
#include <stack>
#include <streambuf>
#include <string>
#include <tuple>
#include <type_traits>
#include <variant>
#define int ll
#define INT128_MAX (__int128)(((unsigned __int128) 1 << ((sizeof(__int128) * __CHAR_BIT__) - 1)) - 1)
#define INT128_MIN (-INT128_MAX - 1)
#define clock chrono::steady_clock::now().time_since_epoch().count()
#ifdef DEBUG
#define dbg(x) cout << (#x) << " = " << x << '\n'
#else
#define dbg(x)
#endif
namespace R = std::ranges;
namespace V = std::views;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ldb = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
//#define double ldb
template<class T>
ostream& operator<<(ostream& os, const pair<T, T> pr) {
return os << pr.first << ' ' << pr.second;
}
template<class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N> &arr) {
for(const T &X : arr)
os << X << ' ';
return os;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T> &vec) {
for(const T &X : vec)
os << X << ' ';
return os;
}
template<class T>
ostream& operator<<(ostream& os, const set<T> &s) {
for(const T &x : s)
os << x << ' ';
return os;
}
//note: inversion only works when MOD is a prime
struct mint {
static long long MOD;
long long _val;
mint(long long init = 0) {
_val = init % MOD;
(*this).norm();
}
mint POW(long long index) {
if (index == 0)
return mint(1ll);
mint base = *this;
mint res = (base == 0ll ? 0ll : 1ll);
while(index) {
if (index & 1)
res *= base;
base *= base, index >>= 1;
}
return res;
}
mint inv() { return (*this).POW(MOD - 2); }
mint& norm() {
if (_val >= MOD)
_val -= MOD;
if (_val < 0)
_val += MOD;
return *this;
}
mint& operator+=(mint b) {
_val += b._val;
return (*this).norm();
}
mint& operator-=(mint b) {
_val -= b._val;
return (*this).norm();
}
mint& operator*=(mint b) {
_val = (_val * b._val) % MOD;
return *this;
}
mint& operator/=(mint b) {
_val = (_val * b.inv()._val) % MOD;
return *this;
}
mint& operator++() {
_val += 1;
return (*this).norm();
}
mint& operator--() {
_val -= 1;
return (*this).norm();
}
mint operator++(signed) {
mint tmp = *this;
++(*this);
return tmp;
}
mint operator--(signed) {
mint tmp = *this;
--(*this);
return tmp;
}
mint operator-() { return mint(-_val); }
bool operator==(mint b) { return _val == b._val; }
bool operator!=(mint b) { return _val != b._val; }
friend mint operator+(mint a, mint b) { return a += b; }
friend mint operator-(mint a, mint b) { return a -= b; }
friend mint operator*(mint a, mint b) { return a *= b; }
friend mint operator/(mint a, mint b) { return a /= b; }
friend ostream& operator<<(ostream& os, const mint& b) {
return os << b._val;
}
friend istream& operator>>(istream& is, mint& b) {
long long val;
is >> val;
b = mint(val);
return is;
}
};
ll mint::MOD = 2;
const int C = 100000001;
vector<int> prime;
int mpf[C];
void sieve() {
for(int i = 1; i < C; i++)
mpf[i] = i;
for(int i = 2; i < C; i++) {
if (mpf[i] == i)
prime.emplace_back(i);
for(int P : prime) {
if (P > mpf[i] or i * P >= C)
break;
mpf[i * P] = P;
}
}
}
vector<pii> factorize(int val) {
vector<pii> res;
while(val > 1) {
int p = mpf[val];
res.emplace_back(p, 0);
while(val % p == 0)
res.back().second += 1, val /= p;
}
return res;
}
vector<int> factors(int val) {
vector<int> res(1, 1);
for(auto [p, idx] : factorize(val)) {
vector<int> tmp;
for(int i = 0, base = 1; i <= idx; i++, base *= p)
for(int X : res)
tmp.emplace_back(X * base);
res.swap(tmp);
}
return res;
}
mt19937 rng(clock);
uniform_int_distribution<int> unif(5000000, 5761454);
signed main() {
ios::sync_with_stdio(false), cin.tie(NULL);
sieve();
int n, q, k; cin >> n >> q >> k;
while(k % (mint::MOD = unif(rng)) == 0);
dbg(mint::MOD);
vector<mint> a(n + 1);
for(mint &x : a | V::drop(1))
cin >> x;
mint tmp = k;
for(int i = 1; i <= n; i++)
a[i] *= tmp, tmp *= k;
partial_sum(a.begin(), a.end(), a.begin());
while(q--) {
int l, r; cin >> l >> r;
cout << (a[r] - a[l - 1] == 0 ? "No\n" : "Yes\n");
}
return 0;
}
Misuki