제출 #1122619

#제출 시각아이디문제언어결과실행 시간메모리
1122619nhphucCurtains (NOI23_curtains)C++17
100 / 100
1081 ms75052 KiB
#include <bits/stdc++.h> using namespace std; const int N = 500500; int n, m, q, t[N * 4], lz[N * 4]; string ans[N]; vector<int> adj[N]; vector<pair<int, int>> que[N]; void push (int id, int l, int r){ if (l == r){ return; } for (int i = id * 2; i <= id * 2 + 1; ++i){ t[i] = max(t[i], lz[id]); lz[i] = max(lz[i], lz[id]); } return; } void upd (int id, int l, int r, int u, int v, int x){ push(id, l, r); if (l > v || r < u){ return; } if (l >= u && r <= v){ t[id] = max(t[id], x); lz[id] = max(lz[id], x); return; } int m = l + r >> 1; upd(id * 2, l, m, u, v, x); upd(id * 2 + 1, m + 1, r, u, v, x); t[id] = min(t[id * 2], t[id * 2 + 1]); return; } int get (int id, int l, int r, int u, int v){ push(id, l, r); if (l > v || r < u){ return n; } if (l >= u && r <= v){ return t[id]; } int m = l + r >> 1; return min(get(id * 2, l, m, u, v), get(id * 2 + 1, m + 1, r, u, v)); } int32_t main (){ ios::sync_with_stdio(false); cin.tie(nullptr); if (fopen("test.inp", "r")){ freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } cin >> n >> m >> q; for (int i = 1; i <= m; ++i){ int l, r; cin >> l >> r; adj[r].push_back(l); } for (int i = 1; i <= q; ++i){ int l, r; cin >> l >> r; que[r].push_back({l, i}); } for (int i = 1; i <= n; ++i){ for (int l : adj[i]){ upd(1, 1, n, l, i, l); } for (auto [l, j] : que[i]){ ans[j] = (get(1, 1, n, l, i) == l ? "YES" : "NO"); } } for (int i = 1; i <= q; ++i){ cout << ans[i] << "\n"; } }

컴파일 시 표준 에러 (stderr) 메시지

curtains.cpp: In function 'int32_t main()':
curtains.cpp:54:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:55:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |         freopen("test.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...