QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#696619#9302. Caesar Cipherreal_sigma_teamWA 1223ms54376kbC++233.4kb2024-10-31 23:53:262024-11-04 17:10:25

Judging History

你现在查看的是最新测评结果

  • [2024-11-04 17:10:25]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:WA
  • 用时:1223ms
  • 内存:54376kb
  • [2024-11-04 17:10:09]
  • hack成功,自动添加数据
  • (/hack/1110)
  • [2024-10-31 23:53:26]
  • 评测
  • 测评结果:100
  • 用时:1164ms
  • 内存:53796kb
  • [2024-10-31 23:53:26]
  • 提交

answer

#include <bits/stdc++.h>
#include <immintrin.h>

using namespace std;

using ll = long long;
using ld = long double;
# define x first
# define y second
# define all(x) x.begin(), x.end()
# define rall(x) x.rbegin(), x.rend()

mt19937 mt(123);

void solve();
void init();

int32_t main() {
#ifndef LOCAL
    cin.tie(nullptr)->sync_with_stdio(false);
#endif
    init();
    cout << fixed << setprecision(10);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}

#define int ll

mt19937 rng(time(0));

int mod = (1ll << 61) - 1;

int base = 133770;

int add(int a, int b) {
    return a + b >= mod ? a + b - mod : a + b;
}
int sub(int a, int b) {
    return a >= b ? a - b : a + mod - b;
}
int mul(int a, int b) {
    return (__int128_t)1 * a * b % mod;
}

const int N = 5e5 + 10;

struct elem {
    int hsh = 0, sz = 0;

    elem() = default;
    elem(int x) : hsh(x), sz(1) {}
};

int mx[4 * N], lazy[4 * N], sum[N], pw[N];
elem tr[4 * N];

elem operator+(elem left, elem right) {
    elem res;
    res.hsh = add(left.hsh, mul(pw[left.sz], right.hsh));
    res.sz = left.sz + right.sz;
    return res;
}

void apply(int node, int x) {
    mx[node] += x;
    tr[node].hsh = add(tr[node].hsh, mul(x, sum[tr[node].sz]));
    lazy[node] += x;
}
void push(int node) {
    apply(node << 1, lazy[node]);
    apply(node << 1 | 1, lazy[node]);
    lazy[node] = 0;
}

int a[N];
void build(int node, int l, int r) {
    if (l == r) {
        mx[node] = a[l];
        tr[node] = elem(a[l]);
    } else {
        int m = (l + r) / 2;
        build(node << 1, l, m);
        build(node << 1 | 1, m + 1, r);
        tr[node] = tr[node << 1] + tr[node << 1 | 1];
        mx[node] = max(mx[node << 1], mx[node << 1 | 1]);
    }
}

void update(int ql, int qr, int node, int l, int r) {
    if (r < ql || qr < l) return;
    if (ql <= l && r <= qr) {
        if (l == r) {
            mx[node] = (mx[node] + 1) % 65536;
            tr[node] = elem(mx[node]);
            return;
        } else if (mx[node] + 1 < 65536) {
            apply(node, 1ll);
            return;
        }
    }
    int m = (l + r) / 2;
    push(node);
    update(ql, qr, node << 1, l, m);
    update(ql, qr, node << 1 | 1, m + 1, r);
    tr[node] = tr[node << 1] + tr[node << 1 | 1];
    mx[node] = max(mx[node << 1], mx[node << 1 | 1]);
}

elem get(int ql, int qr, int node, int l, int r) {
    if (r < ql || qr < l) return elem();
    if (ql <= l && r <= qr) return tr[node];
    int m = (l + r) / 2;
    push(node);
    return get(ql, qr, node << 1, l, m) + get(ql, qr, node << 1 | 1, m + 1, r);
}

void init() {}

void solve() {
    while (base <= 1e5) base = rng();
    int n, q;
    cin >> n >> q;
    pw[0] = 1;
    for (int i = 1; i < n; ++i) pw[i] = mul(pw[i - 1], base);
    for (int i = 0; i < n; ++i) sum[i + 1] = add(sum[i], pw[i]);
    for (int i = 0; i < n; ++i) cin >> a[i];
    build(1, 0, n - 1);
    while (q--) {
        int type;
        cin >> type;
        if (type == 1) {
            int l, r;
            cin >> l >> r;
            --l, --r;
            update(l, r, 1, 0, n - 1);
        } else {
            int a, b, len;
            cin >> a >> b >> len;
            --a, --b;
            if (get(a, a + len - 1, 1, 0, n - 1).hsh == get(b, b + len - 1, 1, 0, n - 1).hsh) cout << "yes\n";
            else cout << "no\n";
        }
    }
}

详细

Test #1:

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

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: 1ms
memory: 9800kb

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: 0ms
memory: 10116kb

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: 173ms
memory: 25700kb

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: 1223ms
memory: 51060kb

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: 1072ms
memory: 53568kb

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: 1062ms
memory: 51056kb

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: 872ms
memory: 53308kb

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: 901ms
memory: 54376kb

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: 871ms
memory: 53844kb

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: 883ms
memory: 52684kb

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: 15ms
memory: 43940kb

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: -3
Extra Test Failed : Wrong Answer on 17
time: 1ms
memory: 10020kb

input:

100 1
7 0 5 0 0 0 9 0 12 14 0 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 0 0 3 0 17 5 13 0 2 0 0 2 0 13 5 17 0 3 0 0 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 0 14 12 0 9 0 0 0 5 0 7
2 1 51 50

output:

yes

result:

wrong answer expected NO, found YES [1st token]