QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#644282#9302. Caesar CiphercastcWA 1207ms87272kbC++205.3kb2024-10-16 12:44:262024-10-21 09:31:48

Judging History

你现在查看的是测评时间为 2024-10-21 09:31:48 的历史记录

  • [2024-11-04 17:10:09]
  • hack成功,自动添加数据
  • (/hack/1110)
  • [2024-10-21 09:47:48]
  • hack成功,自动添加数据
  • (/hack/1022)
  • [2024-10-21 09:40:14]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:WA
  • 用时:1335ms
  • 内存:87276kb
  • [2024-10-21 09:39:50]
  • hack成功,自动添加数据
  • (/hack/1021)
  • [2024-10-21 09:31:48]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:1207ms
  • 内存:87272kb
  • [2024-10-21 09:31:34]
  • hack成功,自动添加数据
  • (/hack/1020)
  • [2024-10-16 12:44:27]
  • 评测
  • 测评结果:100
  • 用时:1248ms
  • 内存:87272kb
  • [2024-10-16 12:44:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define int long long
template<class Info, class Tag>
struct LazySegmentTree {
    const int n;
    vector<Info> info;
    vector<Tag> tag;
    LazySegmentTree(int n) : n(n), info(4 << __lg(n)), tag(4 << __lg(n)) {}
    LazySegmentTree(vector<Info> init) : LazySegmentTree(init.size()) {
        function<void(int, int, int)> build = [&](int p, int l, int r) {
            if (l == r) {
                info[p] = init[l];
                return;
            }
            int m = (l + r) / 2;
            build(2 * p, l, m);
            build(2 * p + 1, m + 1, r);
            pull(p);
        };
        build(1, 0, n - 1);
    }
    void pull(int p) {
        info[p] = info[2 * p] + info[2 * p + 1];
    }
    void apply(int p, const Tag &v) {
        info[p].apply(v);
        tag[p].apply(v);
    }
    void push(int p) {
        apply(2 * p, tag[p]);
        apply(2 * p + 1, tag[p]);
        tag[p] = Tag();
    }
    void modify(int p, int l, int r, int x, const Info &v) {
        if (l == r) {
            info[p] = v;
            return;
        }
        int m = (l + r) / 2;
        push(p);
        if (x <= m) {
            modify(2 * p, l, m, x, v);
        } else {
            modify(2 * p + 1, m + 1, r, x, v);
        }
        pull(p);
    }
    void modify(int p, const Info &v) {
        modify(1, 0, n - 1, p, v);
    }
    Info rangeQuery(int p, int l, int r, int x, int y) {
        if (l > y || r < x) {
            return Info();
        }
        if (l >= x && r <= y) {
            return info[p];
        }
        int m = (l + r) / 2;
        push(p);
        return rangeQuery(2 * p, l, m, x, y) + rangeQuery(2 * p + 1, m + 1, r, x, y);
    }
    Info rangeQuery(int l, int r) {
        if(l > r) return Info();
        return rangeQuery(1, 0, n - 1, l, r);
    }
    void rangeApply(int p, int l, int r, int x, int y, const Tag &v) {
        if (l > y || r < x) {
            return;
        }
        if (l >= x && r <= y) {
            apply(p, v);
            return;
        }
        int m = (l + r) / 2;
        push(p);
        rangeApply(2 * p, l, m, x, y, v);
        rangeApply(2 * p + 1, m + 1, r, x, y, v);
        pull(p);
    }
    void rangeApply(int l, int r, const Tag &v) {
        return rangeApply(1, 0, n - 1, l, r, v);
    }
    void half(int p, int l, int r) {
        if (info[p].act == 0) {
            return;
        }
        if ((info[p].min + 1) / 2 == (info[p].max + 1) / 2) {
            apply(p, {-(info[p].min + 1) / 2});
            return;
        }
        int m = (l + r) / 2;
        push(p);
        half(2 * p, l, m);
        half(2 * p + 1, m + 1, r);
        pull(p);
    }
    void half() {
        half(1, 0, n - 1);
    }
};
const int mod = 1247493647;
const int P = 65536;
const int N = 5e5 + 9;
int pw[N];
struct Tag {
    ll add = 0;
    
    void apply(Tag t) {
        add += t.add;
    }
};

struct Info {
    int ans = 0, add = 0, g = 0, sum = 0;
    
    void apply(Tag t) {
        ans += t.add * add % mod;
        sum += t.add * g;
    }
};

Info operator+(Info a, Info b) {
    Info c;
    if(a.add == 0) return b;
    if(b.add == 0) return a;    
    c.sum = (a.sum + b.sum) % P;
    c.ans = (a.ans * pw[b.g] + b.ans) % mod;
    c.add = (a.add * pw[b.g] + b.add) % mod;
    c.g = a.g + b.g;
    return c;
}
void solve() {
    pw[0] = 1;
    for(int i = 1; i < N; i++) {
        pw[i] = pw[i - 1] * 131;
        pw[i] %= mod;
    }
    int n, q;
    cin >> n >> q;
    vector<Info> init(n);
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        init[i].add = 1;
        init[i].g = 1;
    } 
    for(int i = 0; i < n; i++) {
        if(i == 0) b[i] = a[i];
        else b[i] = a[i] - a[i - 1];
        b[i] += P;
        b[i] %= P;
        init[i].sum = init[i].ans = b[i];
    }
    LazySegmentTree<Info, Tag> seg(init);
    while(q--) {
        int op;
        cin >> op;
        if(op == 1) {
            int l, r;
            cin >> l >> r;
            l--;
            auto p = seg.rangeQuery(l, l);
            p.ans++;
            p.ans %= P;
            p.sum = p.ans;
            seg.modify(l, p);
            if(r < n) {
                p = seg.rangeQuery(r, r);
                p.ans--;
                p.ans += P;
                p.ans %= P;
                p.sum = p.ans;
                seg.modify(r, p);
            }
        } else {
            int x, y, L;
            cin >> x >> y >> L;
            x--, y--;
            int flag = seg.rangeQuery(x + 1, x + L - 1).ans;
            flag -= seg.rangeQuery(y + 1, y + L - 1).ans;
            if(flag != 0) {
                cout << "no\n";
            } else {
                if(seg.rangeQuery(0, x).sum == seg.rangeQuery(0, y).sum) {
                    cout << "yes\n";
                } else {
                    cout << "no\n";
                }
            }
        }
    }
}          
    
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int T = 1;
    // cin >> T;
    while(T--) solve();

    return 0;
}

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

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 7508kb

input:

5 6
1 2 1 2 1
2 1 2 2
2 1 3 3
1 1 1
1 3 5
2 1 2 4
2 1 2 2

output:

no
yes
no
yes

result:

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

Test #2:

score: 0
Accepted
time: 3ms
memory: 7536kb

input:

3 3
0 65535 65535
2 1 2 2
1 2 3
2 1 2 2

output:

no
yes

result:

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

Test #3:

score: 0
Accepted
time: 4ms
memory: 7668kb

input:

1000 1000
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 0 0 ...

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 1000 token(s): yes count is 1000, no count is 0

Test #4:

score: 0
Accepted
time: 184ms
memory: 25028kb

input:

100000 100000
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:

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 100000 token(s): yes count is 100000, no count is 0

Test #5:

score: 0
Accepted
time: 1207ms
memory: 87140kb

input:

500000 500000
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:

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 500000 token(s): yes count is 500000, no count is 0

Test #6:

score: 0
Accepted
time: 1069ms
memory: 87272kb

input:

500000 500000
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:

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 500000 token(s): yes count is 500000, no count is 0

Test #7:

score: 0
Accepted
time: 1035ms
memory: 87088kb

input:

500000 500000
65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 65535 65534 6553...

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
no
no
no
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
no
yes
...

result:

ok 500000 token(s): yes count is 449947, no count is 50053

Test #8:

score: 0
Accepted
time: 791ms
memory: 87232kb

input:

500000 500000
49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 49999 49997 4999...

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
no
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
no
yes
yes
yes
yes
yes
no
yes
yes
yes
yes
yes
yes
yes
yes
yes
no
yes
no
yes
y...

result:

ok 251941 token(s): yes count is 226844, no count is 25097

Test #9:

score: 0
Accepted
time: 707ms
memory: 87160kb

input:

500000 500000
65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 ...

output:

no
no
no
no
no
no
no
no
yes
no
no
yes
no
no
no
no
no
no
no
no
no
no
yes
yes
no
no
yes
no
no
yes
no
no
no
yes
no
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
no
no
yes
no
no
no
no
no
no
no
no
no
yes
no
no
no
no
no
no
no
no
no
no
no
yes
yes
no
no
no
yes
no
no
no
no
yes...

result:

ok 251981 token(s): yes count is 32353, no count is 219628

Test #10:

score: 0
Accepted
time: 807ms
memory: 87052kb

input:

500000 500000
0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 65535 0 6553...

output:

yes
yes
yes
yes
no
no
no
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
no
yes
no
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
no
yes
yes
yes
yes
yes
yes
no
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
no
...

result:

ok 251952 token(s): yes count is 227079, no count is 24873

Test #11:

score: 0
Accepted
time: 691ms
memory: 87084kb

input:

500000 500000
2 1 2 3 1 2 3 2 3 3 3 2 3 2 2 3 3 1 1 2 1 1 3 1 2 2 1 2 1 2 3 1 1 3 2 2 3 3 3 1 3 1 2 3 3 3 3 1 1 3 1 1 3 2 2 3 1 3 1 2 1 1 1 3 2 1 1 2 3 1 3 3 1 3 2 2 3 3 2 3 2 1 3 2 3 3 2 3 1 1 2 1 3 3 3 2 1 2 1 1 1 1 3 1 3 1 1 3 2 1 3 2 1 1 3 3 1 3 1 3 1 2 2 1 1 1 2 2 1 1 1 3 3 1 2 3 3 2 1 3 3 1 2 ...

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
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...

result:

ok 251970 token(s): yes count is 4568, no count is 247402

Test #12:

score: 0
Accepted
time: 18ms
memory: 69984kb

input:

282544 1
0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 0 1...

output:

no

result:

ok NO

Extra Test:

score: 0
Extra Test Passed