Submission #1102878

#TimeUsernameProblemLanguageResultExecution timeMemory
1102878blackslexCurtains (NOI23_curtains)C++17
100 / 100
1016 ms72776 KiB
#include<bits/stdc++.h> #define lsb(x) (x &(-x)) using namespace std; using pii = pair<int, int>; const int N = 5e5 + 5; int n, m, q, x, y, segm[N * 4], lz[N * 4]; void push (int l, int r, int idx) { segm[idx] = max(segm[idx], lz[idx]); if (l < r) { lz[idx * 2 + 1] = max(lz[idx * 2 + 1], lz[idx]); lz[idx * 2 + 2] = max(lz[idx * 2 + 2], lz[idx]); } lz[idx] = 0; } void upd (int l, int r, int idx, int tl, int tr, int val) { push(l, r, idx); if (l > tr || r < tl) return; if (l >= tl && r <= tr) { lz[idx] = max(lz[idx], val); push(l, r, idx); return; } int mid = (l + r) >> 1; upd(l, mid, idx * 2 + 1, tl, tr, val); upd(mid + 1, r, idx * 2 + 2, tl, tr, val); segm[idx] = min(segm[idx * 2 + 1], segm[idx * 2 + 2]); } int qr (int l, int r, int idx, int tl, int tr) { push(l, r, idx); if (l > tr || r < tl) return 1e9; if (l >= tl && r <= tr) return segm[idx]; int mid = (l + r) >> 1; return min(qr(l, mid, idx * 2 + 1, tl, tr), qr(mid + 1, r, idx * 2 + 2, tl, tr)); } int main() { scanf("%d %d %d", &n, &m, &q); vector<vector<int>> add(n + 5, vector<int>()); vector<vector<pii>> cq(n + 5, vector<pii>()); vector<int> ans(q); for (int i = 0; i < m; i++) { scanf("%d %d", &x, &y); add[y].emplace_back(x); } for (int i = 0; i < q; i++) { scanf("%d %d", &x, &y); cq[y].emplace_back(x, i); } for (int i = 1; i <= n; i++) { for (auto &e: add[i]) upd(1, n, 0, e, i, e); for (auto &[x, y]: cq[i]) ans[y] = (qr(1, n, 0, x, i) >= x); } for (auto &e: ans) printf("%s\n", e ? "YES" : "NO"); }

Compilation message (stderr)

curtains.cpp: In function 'int main()':
curtains.cpp:42:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |     scanf("%d %d %d", &n, &m, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         scanf("%d %d", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~
curtains.cpp:51:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |         scanf("%d %d", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...