QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#537302#8338. Quad Kingdoms ChessPhangWA 104ms12124kbC++142.1kb2024-08-30 09:36:332024-08-30 09:36:33

Judging History

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

  • [2024-08-30 09:36:33]
  • 评测
  • 测评结果:WA
  • 用时:104ms
  • 内存:12124kb
  • [2024-08-30 09:36:33]
  • 提交

answer

#include<bits/stdc++.h>
#define rep1(i, a, b) for(int i = a; i <= b; ++i)
#define rep2(i, a, b) for(int i = a; i >= b; --i)
#define ft first
#define sd second
#define pii pair <int, int> 
#define ll long long
#define pb push_back
#define ptc putchar
#define ld long double
#define ull unsigned ll
#define debug puts("------------------")
const int N = 2e5 + 10;
using namespace std;
int q, n1, n2; ll hs[N];
struct sgmtree {
    #define ls x << 1
    #define rs x << 1 | 1
    int a[N], tp, n, mx[N << 2]; ll v[N << 2];
    ll query(int q, int x, int l, int r) {
        if(mx[x] < q) return 0;
        if(l == r) return v[x];
        int mid = l + r >> 1;
        if(mx[rs] < q) return query(q, ls, l, mid);
        else return v[x] ^ v[rs] ^ query(q, rs, mid + 1, r);
    }
    void pushup(int x, int l, int r) {
        mx[x] = max(mx[ls], mx[rs]);
        int mid = l + r >> 1;
        v[x] = v[rs] ^ query(mx[rs], ls, l, mid);
    }
    void build(int x, int l, int r) {
        if(l == r) return v[x] = hs[a[l]], mx[x] = a[l], void();
        int mid = l + r >> 1;
        build(ls, l, mid); build(rs, mid + 1, r);
        pushup(x, l, r);
    }
    void modify(int q, int k, int x, int l, int r) {
        if(l == r) return v[x] = hs[k], mx[x] = k, void();
        int mid = l + r >> 1;
        if(q <= mid) modify(q, k, ls, l, mid);
        else modify(q, k, rs, mid + 1, r);
        pushup(x, l, r);
    }
    #undef ls
    #undef rs
} t1, t2;
int main() {
    mt19937 rand(time(0));
    rep1(i, 1, 2e5) hs[i] = rand();
    // rep1(i, 1, 100) cout << hs[i] << ' '; puts("");
    cin >> t1.n;
    rep1(i, 1, t1.n) cin >> t1.a[i];
    cin >> t2.n;
    rep1(i, 1, t2.n) cin >> t2.a[i];
    t1.build(1, 1, t1.n); t2.build(1, 1, t2.n);
    cin >> q;
    rep1(i, 1, q) {
        int op, x, k; cin >> op >> x >> k;
        if(op == 1) t1.modify(x, k, 1, 1, t1.n);
        else t2.modify(x, k, 1, 1, t2.n);
        // if(q == 31) {cout << "NO\n"; continue;}
        cout << (t1.v[1] == t2.v[1] ? "YES" : "NO") << '\n';
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 11448kb

input:

5
1 2 3 4 5
5
5 4 3 2 1
8
1 1 5
1 4 2
1 2 4
1 5 1
1 5 5
2 1 4
2 3 5
2 5 5

output:

NO
NO
NO
YES
NO
NO
NO
YES

result:

ok 8 tokens

Test #2:

score: -100
Wrong Answer
time: 104ms
memory: 12124kb

input:

1
2
6
2 1 1 1 1 1
200000
2 6 2
1 1 1
1 1 1
1 1 2
2 1 1
1 1 2
1 1 1
2 4 1
2 1 2
1 1 1
1 1 2
2 5 1
1 1 1
1 1 2
1 1 1
2 6 1
1 1 2
1 1 2
1 1 2
2 3 1
1 1 1
2 1 1
2 6 2
1 1 2
2 4 1
1 1 2
2 6 1
1 1 2
1 1 1
2 5 2
2 6 2
1 1 1
2 4 2
2 5 2
2 6 2
1 1 1
2 5 1
2 6 2
1 1 2
1 1 1
1 1 1
2 4 1
1 1 2
1 1 2
1 1 2
2 3 2...

output:

NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
YES
NO
NO
YES
YES
YES
YES
NO
YES
YES
YES
NO
NO
NO
YES
NO
NO
YES
YES
YES
NO
NO
YES
YES
NO
YES
YES
YES
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
NO
NO
NO
YE...

result:

wrong answer 48th words differ - expected: 'NO', found: 'YES'