QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#536692 | #8338. Quad Kingdoms Chess | Phang | WA | 94ms | 14136kb | C++14 | 1.9kb | 2024-08-29 15:47:21 | 2024-08-29 15:47:22 |
Judging History
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 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; ll v[N << 2], mx[N << 2];
ll query(ll 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[ls] ^ 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_64 rand(time(0));
rep1(i, 1, 2e5) hs[i] = rand();
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);
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: 0ms
memory: 14136kb
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: 94ms
memory: 14132kb
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 YES YES 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 NO NO NO NO NO YES YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO NO NO YES YES YES YES N...
result:
wrong answer 31st words differ - expected: 'NO', found: 'YES'