QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#358706 | #8338. Quad Kingdoms Chess | Kirill22# | WA | 24ms | 3792kb | C++23 | 2.3kb | 2024-03-19 22:53:12 | 2024-03-19 22:53:13 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
struct tree {
vector<int> t, c;
void build(int v, int l, int r, const vector<int>& a) {
if (l + 1 == r) {
t[v] = a[l];
c[v] = 1;
return;
}
int m = (l + r) / 2;
build(v * 2 + 1, l, m, a);
build(v * 2 + 2, m, r, a);
t[v] = t[v * 2 + 1], c[v] = c[v * 2 + 1];
if (t[v * 2 + 2] > t[v]) {
t[v] = t[v * 2 + 2], c[v] = c[v * 2 + 2];
} else if (t[v * 2 + 2] == t[v]) {
c[v] += c[v * 2 + 2];
}
// cout << v << " " << l << " " << r << " " << t[v] << endl;
}
tree(int n, const vector<int>& a) {
t.resize(4 * n);
c.resize(4 * n);
build(0, 0, n, a);
}
void set(int v, int l, int r, int i, int x) {
if (l + 1 == r) {
t[v] = x;
return;
}
int m = (l + r) / 2;
if (i < m) {
set(v * 2 + 1, l, m, i, x);
} else {
set(v * 2 + 2, m, r, i, x);
}
t[v] = t[v * 2 + 1], c[v] = c[v * 2 + 1];
if (t[v * 2 + 2] > t[v]) {
t[v] = t[v * 2 + 2], c[v] = c[v * 2 + 2];
} else if (t[v * 2 + 2] == t[v]) {
c[v] += c[v * 2 + 2];
}
}
};
void solve() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
tree A(n, a);
int m;
cin >> m;
vector<int> b(m);
for (int i = 0; i < m; i++) {
cin >> b[i];
}
tree B(m, b);
int q;
cin >> q;
// cout << A.t[0] << " " << B.t[0] << endl;
while (q--) {
int k, i, x;
cin >> k >> i >> x;
k--, i--;
if (k == 0) {
A.set(0, 0, n, i, x);
} else {
B.set(0, 0, m, i, x);
}
// cout << A.t[0] << " " << B.t[0] << endl;
// cout << A.c[0] << " " << B.c[0] << endl;
if (A.t[0] == B.t[0] && A.c[0] == B.c[0]) {
cout << "YES\n";
} else {
cout << "NO\n";
}
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3588kb
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: 24ms
memory: 3792kb
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 YES YES YES YES 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 ...
result:
wrong answer 17th words differ - expected: 'NO', found: 'YES'