이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int par[20][200005];
int r, c, n, X[200005], Y[200005];
map <int, vector <pi> > mp;
void solve(){
cin >> r >> c >> n;
for(int i = 1; i <= n; i++)cin >> X[i] >> Y[i], mp[X[i]].push_back({Y[i], i});
for(auto &[i, j] : mp){
sort(j.begin(), j.end());
}
for(int i = 1; i <= n; i++){
pi brr = {Y[i], 0};
auto tmp = lower_bound(mp[X[i] + 1].begin(), mp[X[i] + 1].end(), brr) - mp[X[i] + 1].begin();
if(tmp == (int)mp[X[i] + 1].size())par[0][i] = -1;
else par[0][i] = mp[X[i] + 1][tmp].se;
//cout << par[0][i] << ' ';
}
for(int i = 1; i <= 19; i++){
for(int j = 1; j <= n; j++){
if(par[i - 1][j] == -1)par[i][j] = -1;
else par[i][j] = par[i - 1][par[i - 1][j]];
}
}
int q; cin >> q;
while(q--){
int a, b, c, d; cin >> a >> b >> c >> d;
if(a == c){
cout << (b <= d ? "Yes\n" : "No\n");
continue;
}
if(c - a - 1 > n || c < a){
cout << "No\n";
continue;
}
pi brr = {b, 0};
auto tmp = lower_bound(mp[a].begin(), mp[a].end(), brr) - mp[a].begin();
if(tmp == (int)mp[a].size()){
cout << "No\n";
continue;
}
else tmp = mp[a][tmp].se;
//jump c - a times
int cur = tmp;
for(int i = 19; i >= 0; i--){
if((c - a - 1) >> i & 1)cur = par[i][cur];
if(cur == -1)break;
}
if(cur == -1 || Y[cur] > d){
cout << "No\n";
}
else cout << "Yes\n";
}
}
main(){
ios::sync_with_stdio(0);cin.tie(0);
int tc = 1;
//cin >> tc;
for(int tc1=1;tc1<=tc;tc1++){
// cout << "Case #" << tc1 << ": ";
solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
trampoline.cpp:69:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
69 | main(){
| ^~~~
# | 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... |