QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#824982#9774. Same Sumucup-team4435#AC ✓942ms54192kbC++2310.2kb2024-12-21 16:51:072024-12-23 09:16:05

Judging History

你现在查看的是测评时间为 2024-12-23 09:16:05 的历史记录

  • [2025-01-11 12:00:50]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:AC
  • 用时:853ms
  • 内存:54088kb
  • [2025-01-11 11:59:18]
  • hack成功,自动添加数据
  • (/hack/1443)
  • [2024-12-23 17:06:26]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:978ms
  • 内存:54200kb
  • [2024-12-23 17:02:06]
  • hack成功,自动添加数据
  • (/hack/1310)
  • [2024-12-23 16:54:08]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:994ms
  • 内存:54172kb
  • [2024-12-23 16:48:26]
  • hack成功,自动添加数据
  • (/hack/1309)
  • [2024-12-23 16:39:16]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:975ms
  • 内存:54228kb
  • [2024-12-23 16:33:45]
  • hack成功,自动添加数据
  • (/hack/1308)
  • [2024-12-23 16:26:41]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:931ms
  • 内存:54200kb
  • [2024-12-23 16:23:53]
  • hack成功,自动添加数据
  • (/hack/1307)
  • [2024-12-23 16:16:10]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:1006ms
  • 内存:54160kb
  • [2024-12-23 16:13:08]
  • hack成功,自动添加数据
  • (/hack/1306)
  • [2024-12-23 15:58:56]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:922ms
  • 内存:54200kb
  • [2024-12-23 15:54:42]
  • hack成功,自动添加数据
  • (/hack/1305)
  • [2024-12-23 15:02:58]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:954ms
  • 内存:54224kb
  • [2024-12-23 14:58:39]
  • hack成功,自动添加数据
  • (/hack/1304)
  • [2024-12-23 10:01:46]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:948ms
  • 内存:54200kb
  • [2024-12-23 09:58:11]
  • hack成功,自动添加数据
  • (/hack/1302)
  • [2024-12-23 09:49:51]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:909ms
  • 内存:54140kb
  • [2024-12-23 09:47:22]
  • hack成功,自动添加数据
  • (/hack/1301)
  • [2024-12-23 09:43:52]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:903ms
  • 内存:54148kb
  • [2024-12-23 09:41:23]
  • hack成功,自动添加数据
  • (/hack/1300)
  • [2024-12-23 09:29:10]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:896ms
  • 内存:54184kb
  • [2024-12-23 09:26:32]
  • hack成功,自动添加数据
  • (/hack/1299)
  • [2024-12-23 09:22:34]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:896ms
  • 内存:54200kb
  • [2024-12-23 09:19:58]
  • hack成功,自动添加数据
  • (/hack/1298)
  • [2024-12-23 09:16:05]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:942ms
  • 内存:54192kb
  • [2024-12-23 09:13:29]
  • hack成功,自动添加数据
  • (/hack/1297)
  • [2024-12-22 18:59:38]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:909ms
  • 内存:54204kb
  • [2024-12-22 18:52:18]
  • hack成功,自动添加数据
  • (/hack/1296)
  • [2024-12-22 18:20:07]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:933ms
  • 内存:54156kb
  • [2024-12-22 18:13:14]
  • hack成功,自动添加数据
  • (/hack/1294)
  • [2024-12-21 16:51:07]
  • 评测
  • 测评结果:100
  • 用时:1001ms
  • 内存:54192kb
  • [2024-12-21 16:51:07]
  • 提交

answer

#include "bits/stdc++.h"


#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
#define rep1n(i, n) for (int i = 1; i <= (n); ++i)
#define repr(i, n) for (int i = (n) - 1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define each(x, a) for (auto &x : a)
#define ar array
#define vec vector
#define range(i, n) rep(i, n)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;

using vi = vector<int>;
using vl = vector<ll>;
using vpi = vector<pair<int, int>>;
using vvi = vector<vi>;

int Bit(int mask, int b) { return (mask >> b) & 1; }

template<class T>
bool ckmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool ckmax(T &a, const T &b) {
    if (b > a) {
        a = b;
        return true;
    }
    return false;
}

// [l, r)
template<typename T, typename F>
T FindFirstTrue(T l, T r, const F &predicat) {
    --l;
    while (r - l > 1) {
        T mid = l + (r - l) / 2;
        if (predicat(mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    return r;
}


template<typename T, typename F>
T FindLastFalse(T l, T r, const F &predicat) {
    return FindFirstTrue(l, r, predicat) - 1;
}

const int INFi = 2e9;
const ll INF = 2e18;

/*
 * Node must have default constructor.
 * Node must have static function merge.
 * Node must have .push and .clear_after_push methods.
*/

template<typename node>
class segtree {
private:
    void build(int v, int vl, int vr) {
        if (vr - vl <= 1)
            return;

        int vm = (vl + vr) >> 1;
        build(v << 1, vl, vm);
        build(v << 1 | 1, vm, vr);
        tree[v] = node::merge(tree[v << 1], tree[v << 1 | 1]);
    }

    template<typename T>
    void build(int v, int vl, int vr, const std::vector<T> &arr) {
        if (vl == vr)
            return;

        if (vr - vl == 1) {
            tree[v] = node(arr[vl]);
            return;
        }

        int vm = (vl + vr) >> 1;
        build(v << 1, vl, vm, arr);
        build(v << 1 | 1, vm, vr, arr);
        tree[v] = node::merge(tree[v << 1], tree[v << 1 | 1]);
    }

    template<typename... Args>
    void _update(int v, int vl, int vr, int l, int r, Args&&... args) {
        if (r <= vl || vr <= l)
            return;

        if (l <= vl && vr <= r) {
            tree[v].apply(std::forward<Args>(args)..., vl, vr);
            return;
        }

        int vm = (vl + vr) >> 1;
        tree[v].push(tree[v << 1], vl, vm);
        tree[v].push(tree[v << 1 | 1], vm, vr);
        tree[v].clear_after_push();

        _update(v << 1, vl, vm, l, r, std::forward<Args>(args)...);
        _update(v << 1 | 1, vm, vr, l, r, std::forward<Args>(args)...);
        tree[v] = node::merge(tree[v << 1], tree[v << 1 | 1]);
    }

    node _query(int v, int vl, int vr, int l, int r) {
        if (l <= vl && vr <= r)
            return tree[v];

        int vm = (vl + vr) >> 1;
        tree[v].push(tree[v << 1], vl, vm);
        tree[v].push(tree[v << 1 | 1], vm, vr);
        tree[v].clear_after_push();

        if (r <= vm)
            return _query(v << 1, vl, vm, l, r);

        if (vm <= l)
            return _query(v << 1 | 1, vm, vr, l, r);

        return node::merge(_query(v << 1, vl, vm, l, r), _query(v << 1 | 1, vm, vr, l, r));
    }

    template<typename T>
    int _find_first(int v, int vl, int vr, int from, const T &checker) {
        if (vr <= from)
            return n;

        if (from <= vl && !checker(tree[v], vl, vr))
            return n;

        if (vr - vl == 1)
            return vl;

        int vm = (vl + vr) >> 1;
        tree[v].push(tree[v << 1], vl, vm);
        tree[v].push(tree[v << 1 | 1], vm, vr);
        tree[v].clear_after_push();

        int res = _find_first(v << 1, vl, vm, from, checker);
        return res == n ? _find_first(v << 1 | 1, vm, vr, from, checker) : res;
    }

    template<typename T>
    int _find_last(int v, int vl, int vr, int from, const T &checker) {
        if (from <= vl)
            return -1;

        if (vr <= from && !checker(tree[v], vl, vr))
            return -1;

        if (vr - vl == 1)
            return vl;

        int vm = (vl + vr) >> 1;
        tree[v].push(tree[v << 1], vl, vm);
        tree[v].push(tree[v << 1 | 1], vm, vr);
        tree[v].clear_after_push();

        int res = _find_last(v << 1 | 1, vm, vr, from, checker);
        return res == -1 ? _find_last(v << 1, vl, vm, from, checker) : res;
    }

public:
    int n;
    std::vector<node> tree;

    segtree(int n) : n(n), tree(4 * n, node()) {
        build(1, 0, n);
    }

    template<typename T>
    segtree(const std::vector<T> &arr) : n(arr.size()), tree(4 * n) {
        build(1, 0, n, arr);
    }

    int size() const {
        return n;
    }

    template<typename... Args>
    void update(int l, int r, Args&&... args) {
        if (r <= l)
            return;

        _update(1, 0, n, l, r, std::forward<Args>(args)...);
    }

    node query(int l, int r) {
        assert(std::max(0, l) < std::min(n, r)); // or return node() in this case
        return _query(1, 0, n, l, r);
    }

    // Trying to find first true on the interval [from, n).
    // Returns n if not found.
    template<typename T>
    int find_first(int from, const T &checker) {
        return _find_first(1, 0, n, from, checker);
    }

    // Trying to find last true on the interval [0, from).
    // Returns -1 if not found.
    template<typename T>
    int find_last(int from, const T &checker) {
        return _find_last(1, 0, n, from, checker);
    }
};

// Node template:
// struct node {
//     node() {}
//     void apply(..., int /* vl */, int /* vr */) {}
//     void push(node /* &child */, int /* cl */, int /* cr */) {}
//     void clear_after_push() {}
//     static node merge(const node &left, const node &right) {}
// };


const int SZ = 3;
inline static int MOD[SZ], BASE[SZ];
inline static std::vector<int> POWER[SZ];

static void initialize() {
    std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    for (int i = 0; i < SZ; i++) {
        auto is_prime = [&](int x) {
            for (int i = 2; i * i <= x; i++)
                if (x % i == 0)
                    return false;

            return true;
        };

        MOD[i] = int(8e5) + rng() % int(2e8 + 228);
        while (!is_prime(MOD[i]))
            MOD[i]++;

        BASE[i] = rng() % MOD[i];
        if (!(BASE[i] & 1))
            BASE[i]++;

        POWER[i].push_back(1);
    }
}

using Hash = ar<int, SZ>;

inline int add(const int &a, const int &b, const int &md) {
    return a + b >= md ? a + b - md : a + b;
}
inline int sub(const int &a, const int &b, const int &md) {
    return a - b < 0 ? a - b + md : a - b;
}
inline int mul(const int &a, const int &b, const int &md) {
    return (1ll * a * b) % md;
}

int pw(int a, ll b, const int &md) {
    int res = 1;
    for(; b; b >>= 1, a = mul(a, a, md)) if (b & 1) res = mul(res, a, md);
    return res;
}

int rev(int a, const int &md) {
    return pw(a, md - 2, md);
}

struct Upd {
    Hash first;
    Hash second;
    ll us;

    void construct(ll v) {
        us = v;
        rep(i, 3) {
            first[i] = pw(BASE[i], v, MOD[i]);
            second[i] = rev(first[i], MOD[i]);
        }
    }
};

struct node {
    Hash sum;
    Hash inv_sum;
    Upd upd;

    ll s;

    node() : s(0) {
        rep(i, 3) sum[i] = inv_sum[i] = 0;
        rep(i, 3) upd.first[i] = upd.second[i] = 1;
        upd.us = 0;
    }
    node(int x) {
        rep(i, 3) sum[i] = pw(BASE[i], x, MOD[i]);
        rep(i, 3) inv_sum[i] = rev(sum[i], MOD[i]);
        rep(i, 3) upd.first[i] = upd.second[i] = 1;
        s = x;
        upd.us = 0;
    }

    void apply(Upd delta, int vl, int vr) {
        rep(i, 3) {
            sum[i] = mul(sum[i], delta.first[i], MOD[i]);
            inv_sum[i] = mul(inv_sum[i], delta.second[i], MOD[i]);
            upd.first[i] = mul(upd.first[i], delta.first[i], MOD[i]);
            upd.second[i] = mul(upd.second[i], delta.second[i], MOD[i]);
        }
        s += 1ll * (vr - vl) * delta.us;
        upd.us += delta.us;
    }

    void push(node &child, int cl, int cr) {
        child.apply(upd, cl, cr);
    }

    void clear_after_push() {
        rep(i, 3) upd.first[i] = upd.second[i] = 1;
        upd.us = 0;
    }

    static node merge(const node &left, const node &right) {
        node res;
        rep(i, 3) {
            res.sum[i] = add(left.sum[i], right.sum[i], MOD[i]);
            res.inv_sum[i] = add(left.inv_sum[i], right.inv_sum[i], MOD[i]);
        }
        res.s = left.s + right.s;
        return res;
    }
};


void solve() {
    int n, q; cin >> n >> q;
    vi a(n);
    rep(i, n) cin >> a[i];
    segtree<node> st(a);
    rep(_, q) {
        int tp; cin >> tp;
        int l, r; cin >> l >> r;
        l--;
        if (tp == 1) {
            ll v; cin >> v;
            Upd upd;
            upd.construct(v);
            st.update(l, r, upd);
            continue;
        }
        auto res = st.query(l, r);
        ll one = res.s;
        ll p = (r - l) / 2;
        if (one % p) {
            cout << "NO\n";
            continue;
        }
        one /= p;
        Hash F = res.sum;
        Hash S = res.inv_sum;
        rep(i, 3) {
            S[i] = mul(S[i], pw(BASE[i], one, MOD[i]), MOD[i]);
//            cerr << S[i] << ' ' << F[i] << ',';
        }
//        cerr << endl;
        if (F == S) {
            cout << "YES\n";
        } else {
            cout << "NO\n";
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(12) << fixed;
    int t = 1;
    initialize();
//    cin >> t;
    rep(i, t) {
        solve();
    }
    return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3572kb

input:

8 4
1 2 3 4 5 6 7 8
2 1 8
1 1 4 4
2 1 6
2 1 8

output:

YES
NO
YES

result:

ok 3 token(s): yes count is 2, no count is 1

Test #2:

score: 0
Accepted
time: 824ms
memory: 54116kb

input:

200000 200000
0 0 0 1 1 0 2 1 1 2 0 1 0 0 0 2 1 0 1 2 2 1 2 1 2 0 0 2 1 2 1 0 0 2 0 2 1 1 1 2 0 0 0 0 2 0 1 0 0 2 2 1 1 0 0 2 1 0 2 0 2 1 2 1 0 1 2 1 0 1 2 1 2 1 0 1 2 0 1 0 1 1 0 2 1 2 0 2 2 1 1 2 1 2 2 0 0 1 2 0 0 2 2 0 1 2 2 0 0 1 2 1 2 0 2 0 0 2 0 2 1 0 1 1 1 1 2 1 2 0 1 2 1 0 2 1 0 1 1 2 2 0 1 ...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 100047 token(s): yes count is 22, no count is 100025

Test #3:

score: 0
Accepted
time: 839ms
memory: 53988kb

input:

200000 200000
5 5 2 0 1 1 4 1 1 0 4 2 2 5 5 4 1 2 2 0 3 3 3 2 5 4 1 5 1 0 0 4 3 4 2 2 3 1 4 2 0 5 4 0 2 5 5 5 2 2 3 4 0 2 2 5 0 2 3 5 4 0 0 2 1 0 5 3 1 4 5 2 2 3 4 5 0 5 5 5 3 3 0 1 4 3 0 0 3 2 2 0 4 5 5 5 2 4 5 2 5 3 1 1 5 2 1 0 1 0 5 0 0 1 5 1 5 3 1 5 3 5 4 0 2 2 4 2 5 2 3 4 5 4 3 5 2 5 2 4 5 3 4 ...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 99734 token(s): yes count is 10, no count is 99724

Test #4:

score: 0
Accepted
time: 924ms
memory: 54056kb

input:

200000 200000
185447 70128 80288 38126 188018 126450 46081 189881 15377 21028 12588 100061 7218 74518 162803 34448 90998 44793 167718 16370 136024 153269 186316 137564 3082 169700 175712 19214 82647 72919 170919 142138 57755 168197 81575 126456 183138 106882 167154 184388 198667 190302 188371 183732...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 99837 token(s): yes count is 11, no count is 99826

Test #5:

score: 0
Accepted
time: 797ms
memory: 54104kb

input:

200000 200000
0 2 0 2 0 2 1 1 1 1 0 2 2 0 1 1 1 1 2 0 0 2 1 1 0 2 0 2 0 2 2 0 1 1 0 2 1 1 2 0 2 0 1 1 2 0 1 1 2 0 0 2 0 2 2 0 1 1 2 0 1 1 0 2 0 2 2 0 0 2 2 0 1 1 1 1 1 1 2 0 0 2 0 2 0 2 0 2 2 0 0 2 1 1 0 2 0 2 2 0 2 0 1 1 1 1 0 2 0 2 2 0 1 1 0 2 2 0 0 2 2 0 1 1 2 0 1 1 0 2 1 1 2 0 1 1 0 2 1 1 2 0 1 ...

output:

NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
...

result:

ok 99868 token(s): yes count is 34, no count is 99834

Test #6:

score: 0
Accepted
time: 790ms
memory: 53984kb

input:

200000 200000
5 0 5 0 2 3 0 5 1 4 1 4 4 1 1 4 1 4 0 5 4 1 2 3 2 3 5 0 5 0 4 1 1 4 2 3 2 3 0 5 3 2 3 2 3 2 2 3 5 0 4 1 1 4 5 0 1 4 0 5 0 5 4 1 3 2 4 1 2 3 2 3 3 2 1 4 4 1 2 3 0 5 5 0 4 1 0 5 2 3 5 0 5 0 5 0 2 3 2 3 3 2 4 1 0 5 2 3 2 3 5 0 0 5 2 3 3 2 5 0 4 1 0 5 0 5 2 3 1 4 0 5 5 0 3 2 1 4 4 1 5 0 2 ...

output:

NO
YES
YES
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO...

result:

ok 99999 token(s): yes count is 32, no count is 99967

Test #7:

score: 0
Accepted
time: 900ms
memory: 53984kb

input:

200000 200000
185447 14553 70128 129872 80288 119712 38126 161874 188018 11982 126450 73550 46081 153919 189881 10119 15377 184623 21028 178972 12588 187412 100061 99939 7218 192782 74518 125482 162803 37197 34448 165552 90998 109002 44793 155207 167718 32282 16370 183630 136024 63976 153269 46731 1...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 99951 token(s): yes count is 16, no count is 99935

Test #8:

score: 0
Accepted
time: 859ms
memory: 54012kb

input:

200000 200000
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

NO
YES
YES
NO
NO
NO
YES
YES
YES
NO
YES
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO...

result:

ok 99715 token(s): yes count is 40, no count is 99675

Test #9:

score: 0
Accepted
time: 873ms
memory: 54076kb

input:

200000 200000
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

YES
NO
YES
NO
YES
YES
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 100013 token(s): yes count is 34, no count is 99979

Test #10:

score: 0
Accepted
time: 942ms
memory: 54068kb

input:

200000 200000
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

YES
YES
NO
YES
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 99963 token(s): yes count is 34, no count is 99929

Test #11:

score: 0
Accepted
time: 82ms
memory: 3688kb

input:

6 122861
0 0 0 0 0 0
2 1 6
1 1 1 1
2 1 6
1 1 1 1
2 1 6
1 1 1 1
2 1 6
1 1 1 1
2 1 6
1 1 1 1
2 1 6
1 2 2 6
1 3 3 5
1 4 4 5
1 5 5 5
1 6 6 5
2 1 6
1 1 1 1
2 1 6
1 1 1 1
2 1 6
1 1 1 1
2 1 6
1 1 1 1
2 1 6
1 1 1 1
2 1 6
1 2 2 6
1 3 3 5
1 4 4 5
1 5 5 5
1 6 6 5
2 1 6
1 1 1 1
2 1 6
1 1 1 1
2 1 6
1 1 1 1
2 1 6...

output:

YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 46656 token(s): yes count is 4986, no count is 41670

Test #12:

score: 0
Accepted
time: 828ms
memory: 54192kb

input:

200000 200000
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
NO
YES
YES
NO
NO
YES
YES
YES
YES
NO
NO
YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
YES
YES
NO
NO
NO
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
NO
YES
YES
YES
YES
NO
YES
NO
NO
YES
NO
NO
YES
YES
YES
NO
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
NO
NO
NO
NO
Y...

result:

ok 200000 token(s): yes count is 142548, no count is 57452

Test #13:

score: 0
Accepted
time: 769ms
memory: 54084kb

input:

200000 200000
192638 7362 141854 58146 18695 181305 143615 56385 20728 179272 179861 20139 78463 121537 79967 120033 121724 78276 131821 68179 140320 59680 124938 75062 119503 80497 14769 185231 50662 149338 82361 117639 43840 156160 110453 89547 64825 135175 177198 22802 147890 52110 197055 2945 12...

output:

NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
NO
NO
YES
NO
YES...

result:

ok 200000 token(s): yes count is 48250, no count is 151750

Test #14:

score: 0
Accepted
time: 393ms
memory: 54072kb

input:

200000 200000
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

ok 99626 token(s): yes count is 99626, no count is 0

Test #15:

score: 0
Accepted
time: 595ms
memory: 53268kb

input:

197608 196219
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

NO

result:

ok NO

Test #16:

score: 0
Accepted
time: 394ms
memory: 54056kb

input:

200000 200000
192638 141854 18695 143615 20728 179861 78463 79967 121724 131821 140320 124938 119503 14769 50662 82361 43840 110453 64825 177198 147890 197055 123986 43758 8280 150034 76471 159453 87872 155736 157666 86004 64006 177643 1216 5985 55593 136832 69653 148283 122874 29168 48188 163871 13...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 100000 token(s): yes count is 0, no count is 100000

Test #17:

score: 0
Accepted
time: 207ms
memory: 3568kb

input:

4 200000
0 0 0 0
1 1 1 42088
2 1 4
1 1 1 58300
2 1 4
1 1 1 145704
2 1 4
1 1 1 117780
2 1 4
1 1 1 195088
2 1 4
1 1 1 160324
2 1 4
1 1 1 133788
2 1 4
1 1 1 162516
2 1 4
1 1 1 13988
2 1 4
1 1 1 188808
2 1 4
1 1 1 31100
2 1 4
1 1 1 177300
2 1 4
1 1 1 55928
2 1 4
1 1 1 19136
2 1 4
1 1 1 73668
2 1 4
1 1 1...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 100000 token(s): yes count is 0, no count is 100000

Test #18:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

2 1
0 0
2 1 2

output:

YES

result:

ok YES

Test #19:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

2 2
0 0
1 1 1 0
2 1 2

output:

YES

result:

ok YES

Test #20:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

1 1
0
1 1 1 0

output:


result:

ok Empty output

Test #21:

score: 0
Accepted
time: 212ms
memory: 3824kb

input:

4 200000
0 0 0 0
1 2 2 199964
2 1 4
1 1 1 199836
2 1 4
1 1 1 199940
2 1 4
1 2 2 199840
2 1 4
1 1 1 199828
2 1 4
1 2 2 199888
2 1 4
1 1 1 199648
2 1 4
1 2 2 199612
2 1 4
1 1 1 199708
2 1 4
1 2 2 199664
2 1 4
1 1 1 199832
2 1 4
1 2 2 199764
2 1 4
1 2 2 199976
2 1 4
1 1 1 199908
2 1 4
1 1 1 199856
2 1 ...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 100000 token(s): yes count is 8, no count is 99992

Test #22:

score: 0
Accepted
time: 712ms
memory: 53980kb

input:

200000 200000
200000 199999 199998 199997 199996 199995 199994 199993 199992 199991 199990 199989 199988 199987 199986 199985 199984 199983 199982 199981 199980 199979 199978 199977 199976 199975 199974 199973 199972 199971 199970 199969 199968 199967 199966 199965 199964 199963 199962 199961 199960...

output:

YES

result:

ok YES

Test #23:

score: 0
Accepted
time: 797ms
memory: 54168kb

input:

200000 200000
175960 196691 141034 183984 132008 129164 72964 53485 150696 31544 139600 193356 28529 89919 66203 72599 141290 173131 195071 149428 42387 2727 96203 56482 124989 42578 1279 45714 127772 147686 190834 124128 87157 141600 151702 131564 181105 179659 94356 91225 180372 167118 123153 1339...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

ok 20000 token(s): yes count is 20000, no count is 0

Extra Test:

score: 0
Extra Test Passed