QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#748409#8338. Quad Kingdoms ChessDeltaxWA 10ms13888kbC++142.2kb2024-11-14 20:19:332024-11-14 20:19:34

Judging History

你现在查看的是最新测评结果

  • [2024-11-14 20:19:34]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:13888kb
  • [2024-11-14 20:19:33]
  • 提交

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];
		else {
			pair <ull, int> t;
			t = calc(l, r, s, mx[s << 1 | 1]);
			h[s] = t.fi * p[cnt[s << 1 | 1]] + h[s << 1 | 1];
			cnt[s] = cnt[s << 1 | 1] + t.se;
	//		h[s] = t.fi, cnt[s] = t.se;
		}
	}
	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);
	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);
		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: 100
Accepted
time: 0ms
memory: 13888kb

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: 10ms
memory: 11900kb

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:

YES
NO
NO
YES
YES
YES
NO
NO
NO
NO
YES
YES
NO
YES
NO
YES
NO
NO
NO
NO
YES
YES
NO
YES
YES
YES
NO
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
NO
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
NO
YES
YES
YES
NO
NO
NO
NO
NO
YE...

result:

wrong answer 1st words differ - expected: 'NO', found: 'YES'