QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#352521#4429. Gebyte's Grinducup-team1209#WA 6748ms668308kbC++203.5kb2024-03-13 12:01:202024-03-13 12:01:20

Judging History

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

  • [2024-03-13 12:01:20]
  • 评测
  • 测评结果:WA
  • 用时:6748ms
  • 内存:668308kb
  • [2024-03-13 12:01:20]
  • 提交

answer

#include<bits/stdc++.h>
using std::cin, std::cout;
using ll = long long;
using pr = std::pair<int, int>;
namespace rgs = std::ranges;
const int N = 4000005;
const int NN = 2000005;
const ll inf = 5e18;
const ll infx = 2.5e18;
int n, q;
ll H;
struct tag {
	ll ad, l, r;
	ll operator () (ll x) {
		if(x == inf) return x;
		return std::min(std::max(x + ad, l), r);
	}
	tag operator () (tag y) const {
		ll xl = l + y.ad;
		ll xr = r + y.ad;
		if(xr < y.l) return {ad + y.ad, y.l, y.l};
		if(y.r < xl) return {ad + y.ad, y.r, y.r};
		return {ad + y.ad, std::max(xl, y.l), std::min(xr, y.r)};
	}
} I = {0, -infx, infx};
tag get() {
	char c; ll v;
	cin >> c >> v;
	if(c == 'B') return {-v, -1, infx};
	if(c == 'K') return {0, -1, v};
	if(c == 'C') return {0, v, infx};
	assert(0);
}

tag sgt[1 << 23];
ll min[1 << 23];
std::vector<std::pair<int, tag>> vs[NN];
int dead[N];
int p[N];
int stp = 1;
int now;
int ans[N];
std::vector<int> qid[NN];

void clear() {
	for(int i = 1;i <= n;++i) vs[i].clear(), qid[i].clear();
	for(int i = 1;i <= q;++i) {
	}
}
void put(int x, tag v) {
	sgt[x] = sgt[x](v);
	min[x] = v(min[x]);
}
void update(int x) {
	min[x] = std::min(min[x << 1], min[x << 1 | 1]);
}
void build(int cur, int l, int r) {
	min[cur] = inf;
	sgt[cur] = I;
	if(l == r) return ;
	int mid = (l + r) >> 1;
	build(cur << 1, l, mid);
	build(cur << 1 | 1, mid + 1, r);
	update(cur);
}

void down(int x) {
	put(x << 1, sgt[x]);
	put(x << 1 | 1, sgt[x]);
	sgt[x] = I;
}

void apply(int ql, int qr, tag v, int cur = 1, int l = 1, int r = stp) {
	if(ql <= l && r <= qr) return put(cur, v);
	int mid = (l + r) >> 1;
	down(cur);
	if(ql <= mid) apply(ql, qr, v, cur << 1, l, mid);
	if(mid < qr) apply(ql, qr, v, cur << 1 | 1, mid + 1, r);
	update(cur);
}
void kill(int ql, int qr, ll v, int cur = 1, int l = 1, int r = stp) {
	if(min[cur] > v) return ;
	if(ql <= l && r <= qr) {
		if(l == r) {
			min[cur] = inf;
			dead[l] = now;
			return ;
		}
	}
	int mid = (l + r) >> 1;
	down(cur);
	if(ql <= mid) kill(ql, qr, v, cur << 1, l, mid);
	if(mid < qr) kill(ql, qr, v, cur << 1 | 1, mid + 1, r);
	update(cur);
}
void upt(int p, int cur = 1, int l = 1, int r = stp) {
	if(l == r) {
		min[cur] = H;
		return ;
	}
	int mid = (l + r) >> 1;
	down(cur);
	if(p <= mid) upt(p, cur << 1, l, mid);
	else upt(p, cur << 1 | 1, mid + 1, r);
	update(cur);
}
int main() {
#ifdef zqj
	freopen("$.in", "r", stdin);
#endif
	std::ios::sync_with_stdio(false), cin.tie(0);
	int z;
	cin >> z;
	for(int i = 0;i < z;++i) {
		cin >> n >> q >> H;
		for(int i = 1;i <= n;++i) {
			vs[i].emplace_back(1, get());
		}
		stp = 1;
		for(int i = 1;i <= q;++i) {
			char t; int p;
			cin >> t >> p;
			if(t == 'Z') {
				vs[p].emplace_back(stp, get());
			} else {
				qid[p].push_back(stp);
				::p[stp++] = p;
			}
		}
		-- stp;
		if(!stp) continue;
		build(1, 1, stp);
		for(int i = 1;i <= stp;++i) dead[i] = n + 1;
		for(int i = 1;i <= n;++i) {
			for(int x : qid[i]) {
				upt(x);
			}
			auto & tmp = vs[i];
			tmp.emplace_back(stp + 1, tag{});
			now = i;
			for(int i = 0;i + 1 < (int) tmp.size();++i) {
				auto [T, op] = tmp[i];
				if(T == tmp[i + 1].first) {
					continue;
				}
				int l = T, r = tmp[i + 1].first - 1;
				if(op.r != infx) kill(l, r, op.r - 1);
				apply(l, r, op);
				kill(1, stp, 0);
			}
		}
		for(int i = 1;i <= stp;++i) {
			-- dead[i];
			if(dead[i] < p[i]) {
				cout << -1;
			} else {
				cout << dead[i];
			}
			cout << " \n"[i == stp];
		}
		clear();
	}
}

详细

Test #1:

score: 0
Wrong Answer
time: 6748ms
memory: 668308kb

input:

1
2000000 4000000 1000000000000
B 2982992025
B 1226542907
B 2299259203
B 1223702056
B 1407121251
B 340783317
B 1259091208
B 2101980047
B 2611543443
B 2010658889
B 4233714406
B 3112120167
B 2311876255
B 2789960428
B 3008572010
B 1
B 2464951378
B 1364240867
B 2829584762
B 2511437438
B 692948679
B 1113...

output:

833302 238155 1007466 1912727 1483707 996123 913464 595444 1956432 168794 1224759 214012 1606540 541216 578117 1279590 1652446 647870 900696 1010723 1723225 1909185 765245 1770241 994028 135066 146309 423001 379625 188229 561102 1020950 25262 1007466 624537 1150303 892424 856521 175916 1187336 16896...

result:

wrong answer 1st lines differ - expected: '833302', found: '833302 238155 1007466 1912727 ...2000000 2000000 2000000 2000000'