結果

問題 No.2592 おでぶなおばけさん 2
ユーザー siro53siro53
提出日時 2023-12-20 01:58:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 12,365 bytes
コンパイル時間 3,733 ms
コンパイル使用メモリ 233,004 KB
実行使用メモリ 25,020 KB
最終ジャッジ日時 2024-09-27 09:18:52
合計ジャッジ時間 19,191 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,296 KB
testcase_01 AC 33 ms
15,620 KB
testcase_02 AC 58 ms
11,816 KB
testcase_03 AC 34 ms
9,184 KB
testcase_04 AC 37 ms
8,248 KB
testcase_05 AC 64 ms
24,600 KB
testcase_06 AC 61 ms
15,304 KB
testcase_07 AC 78 ms
15,184 KB
testcase_08 AC 60 ms
16,156 KB
testcase_09 AC 32 ms
11,148 KB
testcase_10 AC 46 ms
7,592 KB
testcase_11 AC 62 ms
16,156 KB
testcase_12 AC 29 ms
9,088 KB
testcase_13 AC 124 ms
16,524 KB
testcase_14 AC 127 ms
16,600 KB
testcase_15 AC 118 ms
15,360 KB
testcase_16 AC 131 ms
16,728 KB
testcase_17 AC 144 ms
23,484 KB
testcase_18 AC 120 ms
15,504 KB
testcase_19 AC 108 ms
11,536 KB
testcase_20 AC 111 ms
15,576 KB
testcase_21 AC 100 ms
11,484 KB
testcase_22 AC 134 ms
23,112 KB
testcase_23 AC 146 ms
23,584 KB
testcase_24 AC 128 ms
16,144 KB
testcase_25 AC 100 ms
11,384 KB
testcase_26 AC 98 ms
11,272 KB
testcase_27 AC 155 ms
24,900 KB
testcase_28 AC 146 ms
24,876 KB
testcase_29 AC 146 ms
24,748 KB
testcase_30 AC 144 ms
24,780 KB
testcase_31 AC 184 ms
24,744 KB
testcase_32 AC 143 ms
24,884 KB
testcase_33 AC 145 ms
24,864 KB
testcase_34 AC 148 ms
24,812 KB
testcase_35 AC 170 ms
24,720 KB
testcase_36 AC 151 ms
24,808 KB
testcase_37 AC 153 ms
24,884 KB
testcase_38 AC 147 ms
24,856 KB
testcase_39 AC 147 ms
24,924 KB
testcase_40 AC 184 ms
24,844 KB
testcase_41 AC 144 ms
24,860 KB
testcase_42 AC 147 ms
24,936 KB
testcase_43 AC 144 ms
25,020 KB
testcase_44 AC 145 ms
24,864 KB
testcase_45 AC 150 ms
24,932 KB
testcase_46 AC 147 ms
24,912 KB
testcase_47 AC 140 ms
24,908 KB
testcase_48 AC 139 ms
24,752 KB
testcase_49 AC 144 ms
24,900 KB
testcase_50 AC 147 ms
25,016 KB
testcase_51 AC 143 ms
24,836 KB
testcase_52 AC 132 ms
24,856 KB
testcase_53 AC 136 ms
24,840 KB
testcase_54 AC 138 ms
24,728 KB
testcase_55 AC 139 ms
24,796 KB
testcase_56 AC 140 ms
24,780 KB
testcase_57 AC 39 ms
24,852 KB
testcase_58 AC 149 ms
24,872 KB
testcase_59 AC 141 ms
24,840 KB
testcase_60 AC 148 ms
24,720 KB
testcase_61 AC 142 ms
24,716 KB
testcase_62 AC 144 ms
24,716 KB
testcase_63 AC 147 ms
24,848 KB
testcase_64 AC 150 ms
24,964 KB
testcase_65 AC 137 ms
24,880 KB
testcase_66 WA -
testcase_67 AC 139 ms
24,776 KB
testcase_68 AC 137 ms
24,816 KB
testcase_69 AC 134 ms
24,860 KB
testcase_70 WA -
testcase_71 AC 134 ms
24,944 KB
testcase_72 AC 136 ms
24,892 KB
testcase_73 AC 139 ms
24,712 KB
testcase_74 AC 19 ms
7,268 KB
testcase_75 AC 143 ms
24,960 KB
testcase_76 AC 142 ms
24,924 KB
testcase_77 AC 149 ms
24,904 KB
testcase_78 AC 152 ms
24,944 KB
testcase_79 AC 148 ms
24,868 KB
testcase_80 AC 154 ms
24,748 KB
testcase_81 AC 162 ms
24,748 KB
testcase_82 AC 154 ms
24,856 KB
testcase_83 AC 151 ms
24,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
// input output utils
namespace siro53_io {
    // https://maspypy.github.io/library/other/io_old.hpp
    struct has_val_impl {
        template <class T>
        static auto check(T &&x) -> decltype(x.val(), std::true_type{});

        template <class T> static auto check(...) -> std::false_type;
    };

    template <class T>
    class has_val : public decltype(has_val_impl::check<T>(std::declval<T>())) {
    };

    // debug
    template <class T, enable_if_t<is_integral<T>::value, int> = 0>
    void dump(const T t) {
        cerr << t;
    }
    template <class T, enable_if_t<is_floating_point<T>::value, int> = 0>
    void dump(const T t) {
        cerr << t;
    }
    template <class T, typename enable_if<has_val<T>::value>::type * = nullptr>
    void dump(const T &t) {
        cerr << t.val();
    }
    void dump(__int128_t n) {
        if(n == 0) {
            cerr << '0';
            return;
        } else if(n < 0) {
            cerr << '-';
            n = -n;
        }
        string s;
        while(n > 0) {
            s += (char)('0' + n % 10);
            n /= 10;
        }
        reverse(s.begin(), s.end());
        cerr << s;
    }
    void dump(const string &s) { cerr << s; }
    void dump(const char *s) {
        int n = (int)strlen(s);
        for(int i = 0; i < n; i++) cerr << s[i];
    }
    template <class T1, class T2> void dump(const pair<T1, T2> &p) {
        cerr << '(';
        dump(p.first);
        cerr << ',';
        dump(p.second);
        cerr << ')';
    }
    template <class T> void dump(const vector<T> &v) {
        cerr << '{';
        for(int i = 0; i < (int)v.size(); i++) {
            dump(v[i]);
            if(i < (int)v.size() - 1) cerr << ',';
        }
        cerr << '}';
    }
    template <class T> void dump(const set<T> &s) {
        cerr << '{';
        for(auto it = s.begin(); it != s.end(); it++) {
            dump(*it);
            if(next(it) != s.end()) cerr << ',';
        }
        cerr << '}';
    }
    template <class Key, class Value> void dump(const map<Key, Value> &mp) {
        cerr << '{';
        for(auto it = mp.begin(); it != mp.end(); it++) {
            dump(*it);
            if(next(it) != mp.end()) cerr << ',';
        }
        cerr << '}';
    }
    template <class Key, class Value>
    void dump(const unordered_map<Key, Value> &mp) {
        cerr << '{';
        for(auto it = mp.begin(); it != mp.end(); it++) {
            dump(*it);
            if(next(it) != mp.end()) cerr << ',';
        }
        cerr << '}';
    }
    template <class T> void dump(const deque<T> &v) {
        cerr << '{';
        for(int i = 0; i < (int)v.size(); i++) {
            dump(v[i]);
            if(i < (int)v.size() - 1) cerr << ',';
        }
        cerr << '}';
    }
    template <class T> void dump(queue<T> q) {
        cerr << '{';
        while(!q.empty()) {
            dump(q.front());
            if((int)q.size() > 1) cerr << ',';
            q.pop();
        }
        cerr << '}';
    }

    void debug_print() { cerr << endl; }
    template <class Head, class... Tail>
    void debug_print(const Head &h, const Tail &...t) {
        dump(h);
        if(sizeof...(Tail)) dump(' ');
        debug_print(t...);
    }
    // print
    template <class T, enable_if_t<is_integral<T>::value, int> = 0>
    void print_single(const T t) {
        cout << t;
    }
    template <class T, enable_if_t<is_floating_point<T>::value, int> = 0>
    void print_single(const T t) {
        cout << t;
    }
    template <class T, typename enable_if<has_val<T>::value>::type * = nullptr>
    void print_single(const T t) {
        cout << t.val();
    }
    void print_single(__int128_t n) {
        if(n == 0) {
            cout << '0';
            return;
        } else if(n < 0) {
            cout << '-';
            n = -n;
        }
        string s;
        while(n > 0) {
            s += (char)('0' + n % 10);
            n /= 10;
        }
        reverse(s.begin(), s.end());
        cout << s;
    }
    void print_single(const string &s) { cout << s; }
    void print_single(const char *s) {
        int n = (int)strlen(s);
        for(int i = 0; i < n; i++) cout << s[i];
    }
    template <class T1, class T2> void print_single(const pair<T1, T2> &p) {
        print_single(p.first);
        cout << ' ';
        print_single(p.second);
    }
    template <class T> void print_single(const vector<T> &v) {
        for(int i = 0; i < (int)v.size(); i++) {
            print_single(v[i]);
            if(i < (int)v.size() - 1) cout << ' ';
        }
    }
    template <class T> void print_single(const set<T> &s) {
        for(auto it = s.begin(); it != s.end(); it++) {
            print_single(*it);
            if(next(it) != s.end()) cout << ' ';
        }
    }
    template <class T> void print_single(const deque<T> &v) {
        for(int i = 0; i < (int)v.size(); i++) {
            print_single(v[i]);
            if(i < (int)v.size() - 1) cout << ' ';
        }
    }
    template <class T> void print_single(queue<T> q) {
        while(!q.empty()) {
            print_single(q.front());
            if((int)q.size() > 1) cout << ' ';
            q.pop();
        }
    }

    void print() { cout << '\n'; }
    template <class Head, class... Tail>
    void print(const Head &h, const Tail &...t) {
        print_single(h);
        if(sizeof...(Tail)) print_single(' ');
        print(t...);
    }

    // input
    template <class T, enable_if_t<is_integral<T>::value, int> = 0>
    void input_single(T &t) {
        cin >> t;
    }
    template <class T, enable_if_t<is_floating_point<T>::value, int> = 0>
    void input_single(T &t) {
        cin >> t;
    }
    template <class T, typename enable_if<has_val<T>::value>::type * = nullptr>
    void input_single(T &t) {
        cin >> t;
    }
    void input_single(__int128_t &n) {
        string s;
        cin >> s;
        if(s == "0") {
            n = 0;
            return;
        }
        bool is_minus = false;
        if(s[0] == '-') {
            s = s.substr(1);
            is_minus = true;
        }
        n = 0;
        for(int i = 0; i < (int)s.size(); i++) n = n * 10 + (int)(s[i] - '0');
        if(is_minus) n = -n;
    }
    void input_single(string &s) { cin >> s; }
    template <class T1, class T2> void input_single(pair<T1, T2> &p) {
        input_single(p.first);
        input_single(p.second);
    }
    template <class T> void input_single(vector<T> &v) {
        for(auto &e : v) input_single(e);
    }
    void input() {}
    template <class Head, class... Tail> void input(Head &h, Tail &...t) {
        input_single(h);
        input(t...);
    }
}; // namespace siro53_io
#ifdef DEBUG
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debug_print(__VA_ARGS__)
#else
#define debug(...) (void(0))
#endif
// io setup
struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;
using namespace siro53_io;
// types
using ll = long long;
using i128 = __int128_t;
// input macros
#define INT(...)                                                               \
    int __VA_ARGS__;                                                           \
    input(__VA_ARGS__)
#define LL(...)                                                                \
    ll __VA_ARGS__;                                                            \
    input(__VA_ARGS__)
#define STRING(...)                                                            \
    string __VA_ARGS__;                                                        \
    input(__VA_ARGS__)
#define CHAR(...)                                                              \
    char __VA_ARGS__;                                                          \
    input(__VA_ARGS__)
#define DBL(...)                                                               \
    double __VA_ARGS__;                                                        \
    input(__VA_ARGS__)
#define LD(...)                                                                \
    long double __VA_ARGS__;                                                   \
    input(__VA_ARGS__)
#define UINT(...)                                                              \
    unsigned int __VA_ARGS__;                                                  \
    input(__VA_ARGS__)
#define ULL(...)                                                               \
    unsigned long long __VA_ARGS__;                                            \
    input(__VA_ARGS__)
#define VEC(name, type, len)                                                   \
    vector<type> name(len);                                                    \
    input(name);
#define VEC2(name, type, len1, len2)                                           \
    vector name(len1, vector<type>(len2));                                     \
    input(name);
// other macros
// https://trap.jp/post/1224/
#define OVERLOAD3(_1, _2, _3, name, ...) name
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define REP1(i, n) for(int i = 0; i < int(n); i++)
#define REP2(i, a, b) for(int i = (a); i < int(b); i++)
#define REP(...) OVERLOAD3(__VA_ARGS__, REP2, REP1)(__VA_ARGS__)
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(RALL(v))
#define UNIQUE(v)                                                              \
    sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end()), v.shrink_to_fit()
#define REV(v) reverse(ALL(v))
#define SZ(v) ((int)(v).size())
#define MIN(v) (*min_element(ALL(v)))
#define MAX(v) (*max_element(ALL(v)))
// util const
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
constexpr int MOD2 = 998244353;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
// util functions
void Case(int i) { cout << "Case #" << i << ": "; }
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
template <class T> inline bool chmax(T &a, T b) {
    return (a < b ? a = b, true : false);
}
template <class T> inline bool chmin(T &a, T b) {
    return (a > b ? a = b, true : false);
}
template <class T, int dim>
auto make_vector_impl(vector<int>& sizes, const T &e) {
    if constexpr(dim == 1) {
        return vector(sizes[0], e);
    } else {
        int n = sizes[dim - 1];
        sizes.pop_back();
        return vector(n, make_vector_impl<T, dim - 1>(sizes, e));
    }
}
template <class T, int dim>
auto make_vector(const int (&sizes)[dim], const T &e = T()) {
    vector<int> s(dim);
    for(int i = 0; i < dim; i++) s[i] = sizes[dim - i - 1];
    return make_vector_impl<T, dim>(s, e);
}
#pragma endregion Macros

#include <atcoder/segtree>

const ll mods[5] = {1000000009, 1000000021, 1000000033, 1000000087, 1000000093};
ll powers[5][100000 + 5];

inline ll add(ll a, ll b, ll m) {
    ll res = a + b;
    if(res < 0) res = (m - (-res) % m) % m;
    return res;
}
inline ll mul(ll a, ll b, ll m) {
    if(a < 0) a = (m - (-a) % m) % m;
    else a %= m;
    if(b < 0) b = (m - (-b) % m) % m;
    else b %= m;
    return (a * b) % m;
} 

struct S {
    array<ll, 5> sum;
    int len;
};
S op(S a, S b) {
    int len = a.len + b.len;
    array<ll, 5> res;
    REP(i, 5) res[i] = add(a.sum[i], mul(b.sum[i], powers[i][a.len], mods[i]), mods[i]);
    return {res, len};
}
S e() {
    return {{0, 0, 0, 0, 0}, 0};
}
using segtree = atcoder::segtree<S, op, e>;

int main() {
    INT(N, Q);
    LL(K);
    VEC(a, ll, N);

    REP(i, 5) {
        powers[i][0] = 1;
        REP(j, 100000 + 4) powers[i][j + 1] = mul(powers[i][j], K, mods[i]);
    }
    vector<S> init(N);
    REP(i, N) {
        init[i].len = 1;
        REP(j, 5) {
            ll tmp = a[i];
            if(tmp < 0) tmp = (mods[j] - (-tmp) % mods[j]) % mods[j];
            else tmp %= mods[j];
            init[i].sum[j] = tmp;
        }
    }
    segtree seg(init);

    REP(_, Q) {
        INT(l, r);
        l--;
        auto [sum, len] = seg.prod(l, r);
        bool f = false;
        REP(i, 5) if(sum[i] != 0) f = true;
        print(f ? "Yes" : "No");
    }
}
0