| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 675155 | minhnhatnoe | Trampoline (info1cup20_trampoline) | C++17 | 498 ms | 37908 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int r, c;
const int LG = 20;
vector<pair<int, int>> a;
vector<vector<int>> jmps;
void build_jumps(){
jmps.assign(a.size(), vector<int> (20));
for (int i=a.size()-1; i>=0; i--){
vector<pair<int, int>>::iterator it =
lower_bound(a.begin(), a.end(), make_pair(a[i].first+1, a[i].second));
if (it == a.end() || it->first != a[i].first + 1) it = a.end();
int ptr = it - a.begin();
jmps[i][0] = ptr;
for (int p=1; p<LG; p++){
int dn = jmps[i][p-1];
if (dn == a.size()) jmps[i][p] = a.size();
else jmps[i][p] = jmps[dn][p-1];
}
}
}
int jump(int ptr, int step){
if (ptr == a.size()) return a.size();
if (step > 1000000) return a.size();
if (step == 0) return ptr;
int lg2 = 31 - __builtin_clz(step);
return jump(jmps[ptr][lg2], step - (1<<lg2));
}
bool solve(int xf, int yf, int xt, int yt){
if (yt < yf || xt < xf)
return false;
if (xf == xt)
return true;
vector<pair<int, int>>::iterator it =
lower_bound(a.begin(), a.end(), make_pair(xf, yf));
if (it == a.end() || it->first != xf)
return false;
int ptrstart = it - a.begin();
int dest = jump(ptrstart, xt - xf - 1);
if (dest == a.size() || a[dest].second > yt) return false;
return true;
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
cin >> r >> c;
int n; cin >> n;
a.resize(n);
for (int i=0; i<n; i++)
cin >> a[i].first >> a[i].second;
sort(a.begin(), a.end());
build_jumps();
int t; cin >> t;
while (t--){
int xf, yf, xt, yt; cin >> xf >> yf >> xt >> yt;
if (solve(xf, yf, xt, yt))
cout << "Yes\n";
else
cout << "No\n";
}
}컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
