QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#756153 | #8338. Quad Kingdoms Chess | wangjunrui | WA | 23ms | 5896kb | C++14 | 2.0kb | 2024-11-16 19:11:07 | 2024-11-16 19:11:08 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
constexpr int N = 1e5 + 5;
typedef unsigned long long ull;
mt19937_64 rnd(114514);
__gnu_pbds::gp_hash_table<int, ull> mp;
struct segment
{
int n, a[N];
struct Tree
{
int max;
ull res;
} tree[N * 4];
#define lc (rt << 1)
#define rc (rt << 1 | 1)
inline ull calc(int rt, int l, int r, int val)
{
if (l == r)
{
if (tree[rt].max >= val)
return tree[rt].res;
else
return 0;
}
int mid = (l + r) >> 1;
if (tree[rc].max >= val)
return tree[rt].res ^ tree[rc].res ^ calc(rc, mid + 1, r, val);
else
return calc(lc, l, mid, val);
}
inline void pushup(int rt, int l, int mid)
{
tree[rt].max = max(tree[lc].max, tree[rc].max);
tree[rt].res = calc(lc, l, mid, tree[rc].max) ^ tree[rc].res;
}
inline void build(int rt, int l, int r)
{
if (l == r)
{
tree[rt].max = a[l];
if (!mp[a[l]])
mp[a[l]] = rnd();
tree[rt].res = mp[a[l]];
return;
}
int mid = (l + r) >> 1;
build(lc, l, mid);
build(rc, mid + 1, r);
pushup(rt, l, mid);
}
inline void update(int rt, int l, int r, int pos, int val)
{
if (l == r)
{
tree[rt].max = val;
if (!mp[val])
mp[val] = rnd();
tree[rt].res = mp[val];
return;
}
int mid = (l + r) >> 1;
if (pos <= mid)
update(lc, l, mid, pos, val);
else
update(rc, mid + 1, r, pos, val);
pushup(rt, l, mid);
}
inline void init()
{
cin >> n;
for (int i = 1; i <= n; ++i)
cin >> a[i];
build(1, 1, n);
}
inline void update(int pos, int val)
{
update(1, 1, n, pos, val);
}
inline ull get()
{
return tree[1].res;
}
} a, b;
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
a.init(), b.init();
int q;
cin >> q;
while (q--)
{
int opt, x, y;
cin >> opt >> x >> y;
if (opt == 1)
a.update(x, y);
else
b.update(x, y);
if (a.get() == b.get())
cout << "YES\n";
else
cout << "NO\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5680kb
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: 23ms
memory: 5896kb
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'