QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#439135#8768. Arrested DevelopmentPetroTarnavskyi#RE 0ms0kbC++202.3kb2024-06-11 16:42:522024-06-11 16:42:53

Judging History

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

  • [2024-06-11 16:42:53]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-06-11 16:42:52]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

const db SQRT2 = sqrt(2);

PII merge(const PII& a, const PII& b)
{
	if (a.F != b.F)
		return min(a, b);
	return {a.F, a.S + b.S};
}

struct SegTree
{
	int n;
	vector<PII> t;
	VI lazy;
	void init(int _n)
	{
		n = 1;
		while (n < _n)
			n *= 2;
		t.resize(2 * n - 1);
		lazy.resize(2 * n - 1);
	}
	void build(int v, int tl, int tr, const VI& a)
	{
		if (tr - tl == 1)
		{
			t[v] = {0, a[tl + 1] - a[tl]};
			return;
		}
		int tm = (tl + tr) / 2;
		build(2 * v, tl, tm, a);
		build(2 * v + 1, tm, tr, a);
		t[v] = merge(t[2 * v], t[2 * v + 1]);
	}
	void push(int v, int tl, int tr)
	{
		if (tr - tl > 1)
		{
			lazy[2 * v] += lazy[v];
			lazy[2 * v + 1] += lazy[v];
		}
		t[v].F += lazy[v];
		lazy[v] = 0;
	}
	void upd(int v, int tl, int tr, int l, int r, int d)
	{
		push(v, tl, tr);
		if (r <= tl || tr <= l)
			return;
		if (l <= tl && r <= tr)
		{
			lazy[v] = d;
			push(v, tl, tr);
			return;
		}
		int tm = (tl + tr) / 2;
		upd(2 * v, tl, tm, l, r, d);
		upd(2 * v + 1, tm, tr, l, r, d);
		t[v] = merge(t[2 * v], t[2 * v + 1]);
	}
} st;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(15);
	int q, w;
	cin >> q >> w;
	vector<PII> points(q);
	VI vec = {0, w};
	for (auto& [x, y] : points)
	{
		cin >> x >> y;
		int a = max(0, x - y), b = min(w, x + y);
		vec.PB(a);
		vec.PB(b);
	}
	sort(ALL(vec));
	vec.erase(unique(ALL(vec)), vec.end());
	st.init(SZ(vec) - 1);
	st.build(0, 0, SZ(vec) - 1, vec);
	map<PII, int> mp;
	for (auto [x, y] : points)
	{
		mp[{x, y}] ^= 1;
		int a = max(0, x - y), b = min(w, x + y);
		int idxL = lower_bound(ALL(vec), a) - vec.begin();
		int idxR = lower_bound(ALL(vec), b) - vec.begin();
		int d = mp[{x, y}] == 1 ? 1 : -1;
		st.upd(0, 0, SZ(vec) - 1, idxL, idxR, d);
		auto [mn, cntMn] = st.t[0];
		int ans = w;
		if (mn == 0)
			ans -= cntMn;
		cout << SQRT2 * ans << "\n";
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Runtime Error

input:

4
100 1
1 90
1 20
1 20

output:


result: