求助 D wa*4
查看原帖
求助 D wa*4
902351
Little_x_starTYJ楼主2025/2/1 21:56
#include <bits/stdc++.h>
using namespace std;
#define int long long
struct node {
	int x, y;
} a[200010];
struct nod {
	int t, aa, id;
	inline bool operator < (const nod temp) const {
		if (t != temp.t)
			return t < temp.t;
		return a[aa].y < a[temp.aa].y;
	}
} b[200010];
vector<pair<int, int> > v[200010];
map<int, bool> m;
bool an[200010];
signed main() {
	ios::sync_with_stdio(false);
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n, w;
	cin >> n >> w;
	for (int i = 1; i <= n; i++) {
		cin >> a[i].x >> a[i].y;
		v[a[i].x].push_back({a[i].y, i});
		m[i] = 1;
	}
	for (int i = 1; i <= w; i++)
		sort(v[i].begin(), v[i].end());

	int q;
	cin >> q;
	for (int i = 1; i <= q; i++) {
		cin >> b[i].t >> b[i].aa;
		b[i].id = i;
	}
	sort(b + 1, b + 1 + q);
	int anstime = 0, step = 0;
	for (int i = 1; i <= w; i++) {
		if (v[i].size() == step) {
			anstime = -1;
			break;
		}
		anstime = max(v[i][step].first, anstime);
	}
	step++;
	for (int i = 1; i <= q; i++) {
		if (anstime == -1) {
			an[b[i].id] = 1;
			continue;
		}
		if (anstime <= b[i].t && anstime != -2) {
			anstime = 0;
			for (int i = 1; i <= w; i++) {
				m[v[i][step - 1].second] = 0;
				if (v[i].size() == step) {
					anstime = -2;
				}
				if (anstime >= 0)
					anstime = max(v[i][step].first, anstime);
			}
			step++;
		}
		if (m[b[i].aa]) {
			an[b[i].id] = 1;
		} else {
			an[b[i].id] = 0;
		}

	}
	for (int i = 1; i <= q; i++)
		cout << (an[i] ? "Yes\n" : "No\n");
	return 0;
}
2025/2/1 21:56
加载中...