QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#748492 | #8338. Quad Kingdoms Chess | Deltax | WA | 0ms | 13952kb | C++14 | 2.3kb | 2024-11-14 20:33:12 | 2024-11-14 20:33:13 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mkp make_pair
#define pb push_back
typedef pair <int, int> pii;
typedef unsigned long long ull;
inline int read() {
int x = 0, f = 0;
char c = getchar();
while (!isdigit(c)) {if (c == '-') f = 1; c = getchar();}
while (isdigit(c)) x = (x << 1) + (x << 3) + (c & 15), c = getchar();
return f? -x : x;
}
const ull P = 131;
const int MAXN = 1e5;
ull p[MAXN + 10];
int a[MAXN + 10], b[MAXN + 10];
struct SEG {
ull h[MAXN*4 + 10];
int mx[MAXN*4+10], cnt[MAXN*4+10];
pair <ull, int> calc(int l, int r, int s, int v) {
if (l == r) return mkp(h[s], cnt[s]);
pair <ull, int> t;
int mid = l + r >> 1;
if (mx[s << 1 | 1] >= v) {
t = calc(mid + 1, r, s << 1 | 1, v);
return mkp(h[s << 1] * p[t.se] + t.fi, cnt[s << 1] + t.se);
}
t = calc(l, mid, s << 1, v);
return t;
}
inline void pushup(int l, int r, int s) {
mx[s] = max(mx[s << 1], mx[s << 1| 1]);
if (mx[s << 1] < mx[s << 1 | 1]) h[s] = h[s << 1 | 1], cnt[s] = cnt[s << 1 | 1];
else {
int mid = l + r >> 1;
pair <ull, int> t;
t = calc(l, mid, s << 1, mx[s << 1 | 1]);
h[s << 1] = t.fi, cnt[s << 1] = t.se;
h[s] = h[s << 1] * p[cnt[s << 1 | 1]] + h[s << 1 | 1];
cnt[s] = cnt[s << 1] + cnt[s << 1 | 1];
}
}
void upd(int l, int r, int x, int s, int v) {
if (l == r) {
mx[s] = v;
h[s] = v;
cnt[s] = 1;
return;
}
int mid = l + r >> 1;
if (x <= mid) upd(l, mid, x, s << 1, v);
else upd(mid + 1, r, x, s << 1 | 1, v);
pushup(l, r, s);
}
}seg1, seg2;
int main() {
//freopen ("std.in", "r", stdin);
// freopen ("std.out", "w", stdout);
int n1, n2;
n1 = read();
for (int i = 1; i <= n1; ++i) a[i] = read();
n2 = read();
for (int i = 1; i <= n2; ++i) b[i] = read();
int n = max(n1, n2);
p[0] = 1;
for (int i = 1; i <= n; ++i) p[i] = p[i - 1] * P;
for (int i = 1; i <= n1; ++i) seg1.upd(1, n1, i, 1, a[i]);
for (int i = 1; i <= n2; ++i) seg2.upd(1, n2, i, 1, b[i]);
int m = read();
while (m--) {
int o, x, v;
o = read(), x = read(), v = read();
if (o == 1) seg1.upd(1, n1, x, 1, v);
else if (o == 2) seg2.upd(1, n2, x, 1, v);
cout << seg2.h[1] << endl;
if (seg1.h[1] == seg2.h[1]) printf("YES\n");
else printf("NO\n");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 13952kb
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:
1481543715 NO 1481543715 NO 1481543715 NO 1481543715 YES 1481543715 NO 1187043794 NO 1187078116 NO 9061668 NO
result:
wrong answer 1st words differ - expected: 'NO', found: '1481543715'