自己认为正确,样例过了 WA,咋办啊啊啊啊啊!
若有大佬助蒟蒻一臂之力,感激不尽啊!!
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
pair<int, int> a[200005], b[200005];
vector<int> v[200005], t;
bool cmp(pair<int, int> x, pair<int, int> y) {
return x.second < y.second;
}
int main() {
int n, w, mins = 1e9+5, q, A, T, id;
cin >> n >> w;
for (int i = 1; i <= n; i ++) {
cin >> b[i].first >> b[i].second;
a[i] = b[i];
}
sort(a + 1, a + n + 1, cmp);
for (int i = 1; i <= n; i ++) {
v[a[i].first].push_back(a[i].second);
}
for (int i = 1; i <= w; i ++) {
mins = min(mins, (int)v[i].size());
}
t.resize(mins + 5);
for (int j = 1; j <= w; j ++) {
for (int i = 0; i < mins; i ++) {
t[i] = max(t[i], v[j][i]);
}
}
for (int i = 1; i < mins; i ++) {
t[i] = max(t[i], t[i - 1] + 1);
}
cin >> q;
for (int i = 1; i <= q; i ++) {
cin >> T >> A;
id = (int)(lower_bound(v[b[A].first].begin(), v[b[A].first].end(), b[A].second) - v[b[A].first].begin());
cout << (T < t[id] || t[id] == 0 ? "Yes\n" : "No\n");
}
return 0;
}