### AC代码:
```cpp
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <math.h>
#define ll long long
using namespace std;
ll n, m, rain[50005], year[50005];
ll more[50005], gre[50005];
struct cmp {
bool operator()(const ll a, const ll b)const
{
return a > b;
}
};
map<ll, ll> lis;
map<ll, ll, cmp> uos;
stack<ll> nums;
void pre() {
//单调栈,获取正序和逆序不小于rain[i]的第一个下标
for (int i = n; i > 0; i--) {
while (!nums.empty() && rain[nums.top()] <= rain[i]) {
more[nums.top()] = i;
nums.pop();
}
nums.push(i);
}
while (!nums.empty()) {
more[nums.top()] = 0;
nums.pop();
}
for (int i = 1; i <= n; i++) {
while (!nums.empty() && rain[nums.top()] <= rain[i]) {
gre[nums.top()] = i;
nums.pop();
}
nums.push(i);
}
while (!nums.empty()) {
gre[nums.top()] = n + 1;
nums.pop();
}
}
void request(ll y, ll x) {
if (x <= year[1] || y >= year[n]) {
cout << "maybe\n";
return;
}
auto ita = lis.lower_bound(y);
auto itb = uos.lower_bound(x);
ll a = ita->first, b = ita->second;
ll c = itb->first, d = itb->second;
if (c == x && a == y) {
if (more[d] == b) {
if(d - b== x - y) cout << "true\n";
else cout << "maybe\n";
}
else cout << "false\n";
//if (more[d] < b) cout << "maybe\n";
}
else if(c == x && a != y) {
if (more[d] >= b) cout << "false\n";
if (more[d] < b) cout << "maybe\n";
}
else if (c != x && a == y) {
if (gre[b] <= d) cout << "false\n";
if (gre[b] > d) cout << "maybe\n";
}
else {
cout << "maybe\n";
}
}
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> year[i] >> rain[i];
lis.insert({ year[i], i });
uos.insert({ year[i], i });
}
pre();
cin >> m;
for (int i = 0; i < m; i++) {
ll x, y;
cin >> y >> x;
request(y, x);
}
return 0;
}
```
by chaizechen_czc @ 2023-08-29 16:28:08