# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
346792 | 2021-01-11T05:19:22 Z | arnold518 | Trampoline (info1cup20_trampoline) | C++14 | 2000 ms | 35308 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 2e5; int R, C, N, Q; pii A[MAXN+10]; map<int, vector<pii>> M; int par[MAXN+10][30]; int main() { scanf("%d%d%d", &R, &C, &N); for(int i=1; i<=N; i++) { scanf("%d%d", &A[i].first, &A[i].second); M[A[i].first].push_back({A[i].second, i}); } for(auto &it : M) { sort(it.second.begin(), it.second.end()); } for(int i=1; i<=N; i++) { auto it=lower_bound(M[A[i].first+1].begin(), M[A[i].first+1].end(), pii(A[i].second, 0)); if(it==M[A[i].first+1].end()) par[i][0]=0; else par[i][0]=it->second; } A[0]={987654321, 987654321}; for(int i=1; i<=20; i++) for(int j=1; j<=N; j++) par[j][i]=par[par[j][i-1]][i-1]; scanf("%d", &Q); while(Q--) { int y1, x1, y2, x2; scanf("%d%d%d%d", &y1, &x1, &y2, &x2); if(y1==y2 && x1<=x2) { printf("Yes\n"); continue; } auto it=lower_bound(M[y1].begin(), M[y1].end(), pii(x1, 0)); if(it==M[y1].end()) { printf("No\n"); continue; } int now=it->second; while(1) { if(A[par[now][0]].first>=y2) break; now=par[now][0]; } /* for(int i=20; i>=0; i--) { if(A[par[now][i]].first<y2) now=par[now][i]; } */ if(A[now].first!=y2-1) { printf("No\n"); continue; } if(A[now].second<=x2) { printf("Yes\n"); } else { printf("No\n"); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 1644 KB | 200 token(s): yes count is 21, no count is 179 |
2 | Correct | 7 ms | 1772 KB | 200 token(s): yes count is 70, no count is 130 |
3 | Correct | 5 ms | 1388 KB | 197 token(s): yes count is 25, no count is 172 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 239 ms | 28524 KB | 4000 token(s): yes count is 99, no count is 3901 |
2 | Correct | 248 ms | 28424 KB | 4000 token(s): yes count is 91, no count is 3909 |
3 | Correct | 254 ms | 27756 KB | 4000 token(s): yes count is 4000, no count is 0 |
4 | Correct | 241 ms | 28396 KB | 4000 token(s): yes count is 1991, no count is 2009 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2063 ms | 27636 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2050 ms | 1004 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2091 ms | 35308 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |