QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#644665 | #8338. Quad Kingdoms Chess | rikka_lyly | WA | 29ms | 5844kb | C++20 | 2.7kb | 2024-10-16 15:00:41 | 2024-10-16 15:00:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
//两个线段树,维护最大值,最大值的个数,最大值最靠右的地方
#define MAXN 100010
struct Segment
{
int l, r;
int maxval, nums, rightpos;
}tree1[MAXN * 4], tree2[MAXN * 4];
int lc(int p)
{
return p << 1;
}
int rc(int p)
{
return p << 1 | 1;
}
void getup(Segment seg[], int p)
{
if(seg[lc(p)].maxval == seg[rc(p)].maxval)
{
seg[p].maxval = seg[lc(p)].maxval;
seg[p].nums = seg[lc(p)].nums + seg[rc(p)].nums;
seg[p].rightpos = seg[rc(p)].rightpos;
}
else if(seg[lc(p)].maxval > seg[rc(p)].maxval)
{
seg[p].maxval = seg[lc(p)].maxval;
seg[p].nums = seg[lc(p)].nums;
seg[p].rightpos = seg[lc(p)].rightpos;
}
else
{
seg[p].maxval = seg[rc(p)].maxval;
seg[p].nums = seg[rc(p)].nums;
seg[p].rightpos = seg[rc(p)].rightpos;
}
}
void build(Segment seg[], int p, int l, int r, const vector<int>& a)
{
seg[p].l = l, seg[p].r = r;
if(l == r)
{
seg[p].maxval = a[l], seg[p].nums = 1, seg[p].rightpos = l;
return;
}
int mid = (l + r) >> 1;
build(seg, lc(p), l, mid, a);
build(seg, rc(p), mid + 1, r, a);
getup(seg, p);
}
void update(Segment seg[], int p, int x, int y)
{
if(seg[p].l == seg[p].r)
{
// assert(seg[p].l == x);
seg[p].maxval = y, seg[p].nums = 1, seg[p].rightpos = seg[p].l;
return;
}
int mid = (seg[p].l + seg[p].r) >> 1;
if(x <= mid)
update(seg, lc(p), x, y);
else
update(seg, rc(p), x, y);
getup(seg, p);
}
void solve()
{
int n1, n2;
cin >> n1;
vector<int> a1(n1 + 1);
for (int i = 1; i <= n1; i++)
{
cin >> a1[i];
}
cin >> n2;
vector<int> a2(n2 + 1);
for (int i = 1; i <= n2; i++)
{
cin >> a2[i];
}
build(tree1, 1, 1, n1, a1);
build(tree2, 1, 1, n2, a2);
int m;
cin >> m;
while (m--)
{
int opt, x, y;
cin >> opt >> x >> y;
if(opt == 1)
update(tree1, 1, x, y);
else
update(tree2, 1, x, y);
if(tree1[1].maxval == tree2[1].maxval && tree1[1].nums == tree2[1].nums && n1 - tree1[1].rightpos == n2 - tree2[1].rightpos)
{
cout << "YES\n";
}
else
{
cout << "NO\n";
}
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t = 1;
// cin >> t;
while (t--)
{
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5548kb
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: 0
Accepted
time: 26ms
memory: 5844kb
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 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 N...
result:
ok 200000 tokens
Test #3:
score: 0
Accepted
time: 22ms
memory: 5560kb
input:
6 2 1 1 2 1 2 1 1 200000 2 1 1 1 1 2 1 1 1 2 1 2 2 1 1 2 1 1 2 1 2 2 1 2 1 1 2 1 3 1 1 6 2 1 5 2 1 4 2 1 3 1 2 1 2 1 4 2 1 4 2 2 1 2 2 1 2 1 3 1 1 6 1 1 1 2 2 1 1 1 6 1 1 3 1 1 5 2 1 6 2 1 5 2 2 1 2 1 2 1 1 5 2 2 1 1 2 1 1 1 6 1 2 1 2 2 1 1 1 3 2 2 1 1 1 6 1 1 4 2 1 2 1 1 1 1 2 1 1 1 2 1 1 6 2 1 6 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 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 ...
result:
ok 200000 tokens
Test #4:
score: -100
Wrong Answer
time: 29ms
memory: 5672kb
input:
6 1 3 1 2 1 2 6 2 1 3 3 3 1 200000 2 4 2 1 2 1 1 6 2 2 3 2 1 1 1 1 6 2 1 6 2 1 3 2 2 6 1 2 4 3 1 1 2 2 5 2 2 6 2 2 3 1 1 4 3 1 3 1 2 5 2 2 4 2 2 1 3 1 1 1 2 2 2 2 4 2 1 5 3 1 6 3 2 6 3 1 5 3 2 5 3 2 4 1 2 4 2 1 1 2 1 6 1 2 6 1 1 2 3 1 1 3 1 1 1 2 6 3 2 4 1 1 4 2 2 2 1 1 3 1 1 1 3 1 1 3 1 4 3 1 3 3 2...
output:
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 YES YES YES YES 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 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 N...
result:
wrong answer 15th words differ - expected: 'NO', found: 'YES'