QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#353081 | #8338. Quad Kingdoms Chess | ucup-team093 | WA | 28ms | 4596kb | C++20 | 2.3kb | 2024-03-13 20:47:05 | 2024-03-13 20:47:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using big = __int128;
const int N = 1e5 + 10;
mt19937 rnd;
i64 b[N];
struct segTree {
int n, tN;
vector<int> a, maxp;
vector<i64> h;
void merge(int i) {
maxp[i] = max(maxp[i * 2], maxp[i * 2 + 1]);
h[i * 2 + 1] = (i * 2 + 1 >= tN ? b[a[i * 2 + 1 - tN]] : 0);
if(maxp[i * 2] >= maxp[i * 2 + 1]) {
for(int j = i * 2 * 2; j < tN * 2; ) {
if(maxp[j + 1] >= maxp[i * 2 + 1]) j ++;
h[i * 2 + 1] += h[j];
j *= 2;
}
}
}
segTree(vector<int> &v) {
n = v.size();
a = v;
a.insert(a.begin(), 0);
tN = n + 2;
while(tN != (tN & -tN)) tN += (tN & -tN);
maxp = vector<int>(tN * 2);
h = vector<i64>(tN * 2);
for(int i = 1; i <= n; i ++) {
maxp[tN + i] = a[i];
h[tN + i] = b[a[i]];
}
for(int i = tN - 1; i; i --)
merge(i);
}
void modify(int p, int x) {
a[p] = x;
maxp[tN + p] = x;
h[tN + p] = b[x];
for(int j = (tN + p) / 2; j; j /= 2)
merge(j);
}
i64 query() {
i64 ret = 0;
for(int i = tN + n; i; i /= 2)
ret += h[i];
return ret;
}
i64 debug() {
for(int i = 1; i < tN * 2; i ++)
cout << i << ": " << maxp[i] << " " << h[i] << "\n";
i64 ret = 0;
for(int i = tN + n; i; i /= 2)
ret += h[i];
return ret;
}
};
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
rnd = mt19937(1919810);
for(int i = 0; i < N; i ++)
b[i] = rnd();
int n;
cin >> n;
vector<int> v(n);
for(int i = 0; i < n; i ++)
cin >> v[i];
int m;
cin >> m;
vector<int> z(m);
for(int i = 0; i < m; i ++)
cin >> z[i];
vector tr{segTree(v), segTree(z)};
int q;
cin >> q;
for(int i = 0, op, p, x; i < q; i ++) {
cin >> op >> p >> x;
tr[op - 1].modify(p, x);
if(tr[0].query() == tr[1].query()) cout << "YES\n";
else cout << "NO\n";
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 4588kb
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: 25ms
memory: 4336kb
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: 25ms
memory: 4396kb
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: 28ms
memory: 4596kb
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 NO NO NO NO NO NO NO NO NO NO YES YES NO NO NO NO NO NO 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...
result:
wrong answer 25th words differ - expected: 'NO', found: 'YES'