#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a,b) for (int a = 0; a < (b); ++a)
#define pb push_back
#define all(t) t.begin(), t.end()
struct Pole
{
int y=-1, x=-1;
};
struct Element
{
int val, idx;
bool operator < (const Element &element) const
{
return val < element.val;
}
};
const int max_N = 2e5+5;
int wysokosc = 0, szerokosc = 0, n = 0, q = 0, y_1 = 0, y_2 = 0, x_1 = 0, x_2 = 0;
Pole P[max_N];
int nextt[max_N];
map<int,set<Element>> S;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> wysokosc >> szerokosc >> n;
rep(i,n) cin >> P[i].y >> P[i].x;
rep(i,n) S[P[i].y].insert({P[i].x,i});
rep(i,n)
{
int y = P[i].y, x = P[i].x;
if (auto it = S.find(y+1) == S.end())
{
nextt[i] = -1;
continue;
}
auto it = S[y+1].lower_bound({x,-1});
if (it != S[y+1].end()) nextt[i] = it->idx;
else nextt[i] = -1;
}
cin >> q;
rep(z,q)
{
cin >> y_1 >> x_1 >> y_2 >> x_2;
if (y_1 > y_2 or x_1 > x_2)
{
cout << "No" << '\n';
continue;
}
if (y_1 == y_2)
{
cout << "Yes" << '\n';
continue;
}
if (auto it = S.find(y_1) == S.end())
{
cout << "No" << '\n';
continue;
}
if (auto it = S[y_1].lower_bound({x_1,-1}) == S[y_1].end())
{
cout << "No" << '\n';
continue;
}
int akt = (S[y_1].lower_bound({x_1,-1}))->idx, y = P[akt].y, x = P[akt].x;
bool czy_OK = false;
while(y < y_2)
{
++y;
if (y > wysokosc) break;
if (y == y_2 and x <= x_2)
{
czy_OK = true;
break;
}
if (nextt[akt] == -1) break;
akt = nextt[akt], x = P[akt].x;
}
if (czy_OK == true) cout << "Yes" << '\n';
else cout << "No" << '\n';
}
return 0;
}
Compilation message
trampoline.cpp: In function 'int main()':
trampoline.cpp:40:18: warning: unused variable 'it' [-Wunused-variable]
40 | if (auto it = S.find(y+1) == S.end())
| ^~
trampoline.cpp:63:18: warning: unused variable 'it' [-Wunused-variable]
63 | if (auto it = S.find(y_1) == S.end())
| ^~
trampoline.cpp:68:18: warning: unused variable 'it' [-Wunused-variable]
68 | if (auto it = S[y_1].lower_bound({x_1,-1}) == S[y_1].end())
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
984 KB |
200 token(s): yes count is 21, no count is 179 |
2 |
Correct |
5 ms |
860 KB |
200 token(s): yes count is 70, no count is 130 |
3 |
Correct |
3 ms |
856 KB |
197 token(s): yes count is 25, no count is 172 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
157 ms |
12268 KB |
4000 token(s): yes count is 99, no count is 3901 |
2 |
Correct |
167 ms |
12416 KB |
4000 token(s): yes count is 91, no count is 3909 |
3 |
Correct |
153 ms |
12036 KB |
4000 token(s): yes count is 4000, no count is 0 |
4 |
Correct |
170 ms |
12368 KB |
4000 token(s): yes count is 1991, no count is 2009 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
261 ms |
14856 KB |
200000 token(s): yes count is 110486, no count is 89514 |
2 |
Correct |
277 ms |
18516 KB |
200000 token(s): yes count is 114664, no count is 85336 |
3 |
Correct |
279 ms |
18420 KB |
200000 token(s): yes count is 86232, no count is 113768 |
4 |
Correct |
382 ms |
18884 KB |
200000 token(s): yes count is 94603, no count is 105397 |
5 |
Correct |
416 ms |
18680 KB |
200000 token(s): yes count is 94148, no count is 105852 |
6 |
Correct |
409 ms |
24744 KB |
200000 token(s): yes count is 97163, no count is 102837 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
604 KB |
5000 token(s): yes count is 3238, no count is 1762 |
2 |
Correct |
8 ms |
856 KB |
5000 token(s): yes count is 3837, no count is 1163 |
3 |
Correct |
9 ms |
1372 KB |
5000 token(s): yes count is 4104, no count is 896 |
4 |
Correct |
6 ms |
856 KB |
5000 token(s): yes count is 3934, no count is 1066 |
5 |
Correct |
13 ms |
1112 KB |
5000 token(s): yes count is 3384, no count is 1616 |
6 |
Correct |
5 ms |
856 KB |
5000 token(s): yes count is 3390, no count is 1610 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2062 ms |
19728 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |