QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#95005#4429. Gebyte's Grindwhatever#WA 3096ms101668kbC++231.9kb2023-04-08 17:27:462023-04-08 17:27:50

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-08 17:27:50]
  • 评测
  • 测评结果:WA
  • 用时:3096ms
  • 内存:101668kb
  • [2023-04-08 17:27:46]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
constexpr int N = 2e6 + 10;
constexpr i64 inf = 1e18;
int n, q;
i64 H;
struct node {
	i64 lim, x, y;
	friend node operator + (node x, node y) {
		if(x.y <= y.lim) {
			x.lim = x.x + y.lim - x.y;
		}
		if(x.y <= y.x) {
			x.x = min(inf, x.x + y.x - x.y);
			x.y = y.y;
		} else {
			x.y = x.y - y.x + y.y;
		}
		return x;
	}
};
node newnode() {
	char ch; i64 x;
	cin >> ch >> x;
	if(ch == 'C') return {-inf, x, x};
	else if(ch == 'K') return {x - 1, inf, x}; 
	else if(ch == 'B') return {x, x + 1, 1};
}
struct segment {
	#define ls u << 1
	#define rs u << 1 | 1
	node a[N << 2];
	void up(int u) {
		a[u] = a[ls] + a[rs];
	}
	void upd(int u, int l, int r, int ql, int qr, node k){
		if(l == r) return a[u] = k, void();
		int mid = l + r >> 1;
		if(ql <= mid) upd(ls, l, mid, ql, qr, k);
		if(qr > mid) upd(rs, mid + 1, r, ql, qr, k);
		up(u);
	}
	int find(int u, int l, int r, int p, i64 &cur) {
		if(p <= l && cur > a[u].lim) {
			if(cur <= a[u].x) cur = a[u].y;
			else cur = a[u].y + cur - a[u].x;
			return -1;
		}
		if(l == r) return l;
		int mid = l + r >> 1;
		if(p <= mid) {
			int ret = find(ls, l, mid, p, cur);
			return ret == -1 ? find(rs, mid + 1, r, p, cur) : ret;
		} else {
			return find(rs, mid + 1, r, p, cur);
		}
	}
}ds;
void solve() {
	cin >> n >> q >> H;
	for(int i = 1; i <= n; i++) {
		ds.upd(1, 1, n, i, i, newnode());
	}
	for(int i = 0; i < q; i ++) {
		char o;
		cin >> o;
		if(o == 'Z') {
			int p; cin >> p;
			ds.upd(1, 1, n, p, p, newnode());
		} else {
			int p; cin >> p;
			i64 cur = H;
			int q = ds.find(1, 1, n, p, cur);
			cout << (q == - 1 ? n : q == p ? - 1: q - 1) << '\n';
		}
	}
}
int main() {
//	freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(false), cin.tie(0);
	int T;
	for(cin >> T; T; T --) {
		solve();
	}
 	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 3096ms
memory: 101668kb

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 258th lines differ - expected: '504587', found: '751690'