Submission #332229

#TimeUsernameProblemLanguageResultExecution timeMemory
332229evpipisTrampoline (info1cup20_trampoline)C++11
100 / 100
469 ms37996 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back typedef pair<int, int> ii; const int len = 2e5+5, lg = 30, inf = 1e9+5; ii point[len]; int k, dp[len][lg]; int fir(int x, int y){ int l = 1, r = k, ans = k+1; while (l <= r){ int mid = (l+r)/2; if (point[mid] >= mp(x, y)) ans = mid, r = mid-1; else l = mid+1; } if (ans == k+1 || point[ans].fi > x) return 0; return ans; } int main(){ int n, m, q; scanf("%d %d %d", &n, &m, &k); for (int i = 1; i <= k; i++) scanf("%d %d", &point[i].fi, &point[i].se); point[0] = mp(inf, inf); sort(point+1, point+1+k); for (int i = 1; i <= k; i++) dp[i][0] = fir(point[i].fi+1, point[i].se); for (int j = 1; j < lg; j++) for (int i = 1; i <= k; i++) dp[i][j] = dp[dp[i][j-1]][j-1]; scanf("%d", &q); while (q--){ int x1, y1, x2, y2; scanf("%d %d %d %d", &x1, &y1, &x2, &y2); if (x1 > x2 || y1 > y2) printf("No\n"); else if (x1 == x2) printf("Yes\n"); else{ int i = fir(x1, y1), dif = x2-x1-1; for (int j = 0; j < lg; j++) if (dif&(1<<j)) i = dp[i][j]; if (point[i].se <= y2) printf("Yes\n"); else printf("No\n"); } } return 0; }

Compilation message (stderr)

trampoline.cpp: In function 'int main()':
trampoline.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   31 |     scanf("%d %d %d", &n, &m, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
trampoline.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   34 |         scanf("%d %d", &point[i].fi, &point[i].se);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
trampoline.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   45 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
trampoline.cpp:48:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   48 |         scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...