How D!!!!!!!!!!!
  • 板块学术版
  • 楼主I_Love_DS
  • 当前回复10
  • 已保存回复11
  • 发布时间2024/12/21 21:41
  • 上次更新2024/12/22 09:42:21
查看原帖
How D!!!!!!!!!!!
1118614
I_Love_DS楼主2024/12/21 21:41
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int N = 114514;

int n, q, cnt;
ll x, y;

map <ll, set <ll>> heng, zong;

int main() {
	scanf("%d%d%lld%lld", &n, &q, &x, &y);
	for (int i = 1; i <= n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		if (a == x && b == y) {
			++cnt;
			continue;
		}
		heng[a].insert(b);
		zong[b].insert(a);
	}
	while (q--) {
		char op;
		int c;
		cin >> op >> c;
		if (op == 'L') {
			ll sx = x - c;
			auto it1 = zong[y].lower_bound(sx);
			auto it2 = zong[y].lower_bound(x);
			for (auto it = it1; it != it2; ) {
				++cnt;
				heng[*it].erase(y);
				it = zong[y].erase(it);
			}
			x = sx;
		} else if (op == 'R') {
			ll sx = x + c;
			auto it1 = zong[y].lower_bound(x);
			auto it2 = zong[y].lower_bound(sx);
			for (auto it = it1; it != it2; ) {
				++cnt;
				heng[*it].erase(y);
				it = zong[y].erase(it);
			}	
			x = sx;
		} else if (op == 'U') {
			ll sy = y + c;
			auto it1 = heng[x].lower_bound(y);
			auto it2 = heng[x].lower_bound(sy);
			for (auto it = it1; it != it2; ) {
				++cnt;
				zong[*it].erase(x);
				it = heng[x].erase(it);
			}
			y = sy;
		} else if (op == 'D') {
			ll sy = y - c;
			auto it1 = heng[x].lower_bound(sy);
			auto it2 = heng[x].lower_bound(y);
			for (auto it = it1; it != it2; ) {
				++cnt;
				zong[*it].erase(x);
				it = heng[x].erase(it);
			}
			y = sy;
		}
	}
	printf("%lld %lld %d\n", x, y, cnt);
	return 0;
}

又搞 set + map 大型 stl 题。。

2024/12/21 21:41
加载中...