Submission #1264569

#TimeUsernameProblemLanguageResultExecution timeMemory
1264569tminhCurtains (NOI23_curtains)C++20
0 / 100
11 ms23880 KiB
#include "bits/stdc++.h" using namespace std; #define task "" #define ll long long #define endl '\n' #define fi first #define se second #define vall(a) (a).begin(), (a).end() #define sze(a) (int)a.size() #define pii pair<int, int> #define pll pair<ll, ll> #define ep emplace_back #define pb push_back #define pf push_front const ll mod = 1e9 + 7; const int N = 5e5 + 5; const int oo = 1e9; bool START; int n, q, m; struct ST { int st[N << 2], lazy[N << 2]; void push(int id) { st[id << 1] = max(lazy[id], st[id << 1]); st[id << 1 | 1] = max(lazy[id], st[id << 1 | 1]); lazy[id << 1] = max(lazy[id], lazy[id << 1]); lazy[id << 1 | 1] = max(lazy[id], lazy[id << 1 | 1]); lazy[id << 1] = 0; } void update(int id, int l, int r, int u, int v, int val) { if (l > v || r < u) return; if (l >= u && r <= v) { st[id] = max(st[id], val); lazy[id] = max(lazy[id], val); return; } int mid = (l + r) >> 1; if (lazy[id]) push(id); update(id << 1, l, mid, u, v, val); update(id << 1 | 1, mid + 1, r, u, v, val); st[id] = min(st[id << 1], st[id << 1 | 1]); } int get(int id, int l, int r, int u, int v) { if (l > v || r < u) return oo; if (l >= u && r <= v) return st[id]; int mid = (l + r) >> 1; if (lazy[id]) push(id); return min(get(id << 1, l, mid, u, v), get(id << 1 | 1, mid + 1, r, u, v)); } } st; bool ans[N]; vector<int> sw[N]; vector<pii> qr[N]; inline void solve() { for (int r = 1; r <= n; ++r) { for (int l : sw[r]) st.update(1, 1, n, l, r, l); for (auto[l, id] : qr[r]) ans[id] = (st.get(1, 1, n, l, r) >= l); } for (int i = 1; i <= q; ++i) cout << (ans[i] ? "YES" : "NO") << endl; } inline void input() { cin >> n >> m >> q; for (int i = 1; i <= m; ++i) { int l, r; cin >> l >> r; sw[r].pb(l); } for (int i = 1; i <= q; ++i) { int l, r; cin >> l >> r; qr[r].pb(make_pair(l, i)); } return solve(); } bool END; int main() { if(fopen(task ".inp", "r")) { freopen(task ".inp", "r", stdin); freopen(task ".out", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); input(); cerr << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << 's' << endl; cerr << "Memory: " << fabs ((&END - &START)) / 1048576.0 << "MB\n"; return 0; }

Compilation message (stderr)

curtains.cpp: In function 'int main()':
curtains.cpp:92:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   92 |         freopen(task ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:93:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   93 |         freopen(task ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#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...