이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma warning(disable : 6031)
#define USACO freopen("moocast.in", "r", stdin); freopen("moocast.out", "w+", stdout)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
using namespace std;
ll binpow(ll a, ll x, ll m) {
ll ans = 1, md = a % m;
for (int i = 0; i < 63; i++) {
if (x & ((ll)1 << i)) ans = (ans * md) % m;
md = (md * md) % m;
}
return ans;
}
vector<ll> gcd(ll a, ll b) {
if (b == 0) {
return { a, 1, 0 };
}
vector<ll> d = gcd(b, a % b);
return { d[0], d[2], d[1] - d[2] * (a / b) };
}
ll lcm(ll a, ll b) {
return a * b / gcd(a, b)[0];
}
pair<int, int> p[200000];
int f[200000], binlifting[32][200001];
void solve() {
int r, c, n, T;
cin >> r >> c >> n;
for (int i = 0; i < n; i++) cin >> p[i].first >> p[i].second;
sort(p, p + n);
for (int i = 0; i < n; i++) {
auto it = lower_bound(p, p + n, pair<int, int>{p[i].first + 1, p[i].second});
if (it == p + n || it->first != p[i].first + 1) f[i] = n;
else f[i] = it - p;
}
for (int i = 0; i < n; i++) binlifting[0][i] = f[i];
for (int i = 0; i <= 30; i++) binlifting[i][n] = n;
for (int k = 1; k <= 30; k++) {
for (int i = 0; i < n; i++) binlifting[k][i] = binlifting[k - 1][binlifting[k - 1][i]];
}
cin >> T;
while (T--) {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
if (x2 < x1) {
cout << "No\n";
continue;
}
if (x2 == x1) {
if (y1 <= y2) cout << "Yes\n";
else cout << "No\n";
continue;
}
x2--;
int green = lower_bound(p, p + n, pair<int, int>{ x1, y1 }) - p, dist = x2 - x1;
for (int bit = 30; bit >= 0; bit--) {
if (dist & (1 << bit)) green = binlifting[bit][green];
}
if (green != n && p[green].second < y2) cout << "Yes\n";
else cout << "No\n";
}
}
int main() {
//USACO;
fastIO;
solve();
}
컴파일 시 표준 에러 (stderr) 메시지
trampoline.cpp:2: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
2 | #pragma warning(disable : 4996)
|
trampoline.cpp:3: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
3 | #pragma warning(disable : 6031)
|
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |