제출 #1260203

#제출 시각아이디문제언어결과실행 시간메모리
1260203minggaAdvertisement 2 (JOI23_ho_t2)C++20
100 / 100
418 ms18236 KiB
// Author: caption_mingle #include "bits/stdc++.h" using namespace std; #define ln "\n" #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define ll long long const int mod = 1e9 + 7; const int inf = 2e9; const int N = 5e5 + 7; int n, f[N]; pair<int, int> a[N]; vector<int> vx, vy; struct SEGTREE { vector<int> st; int n; SEGTREE() {} SEGTREE(int n) : n(n) { st.resize(n * 4 + 4, 0); } void update(int i, int l, int r, int u, int x) { if(l > u or r < u) return ; if(l == r) { st[i] = x; return; } int m = (l + r) >> 1; update(i * 2, l, m, u, x); update(i * 2 + 1, m + 1, r, u, x); st[i] = max(st[i * 2], st[i * 2 + 1]); } int get(int i, int l, int r, int u, int v) { if(l > v or r < u) return 0; if(u <= l and r <= v) return st[i]; int m = (l + r) >> 1; return max(get(i * 2, l, m, u, v), get(i * 2 + 1, m + 1, r, u, v)); } }; signed main() { cin.tie(0) -> sync_with_stdio(0); #define task "" if(fopen(task ".INP", "r")) { freopen(task ".INP", "r", stdin); freopen(task ".OUT", "w", stdout); } cin >> n; for(int i = 1; i <= n; i++) { int x, e; cin >> x >> e; a[i].fi = e - x; a[i].se = e + x; vx.pb(e - x); vy.pb(e + x); } sort(all(vx)); vx.erase(unique(all(vx)), vx.end()); sort(all(vy)); vy.erase(unique(all(vy)), vy.end()); for(int i = 1; i <= n; i++) { a[i].fi = upper_bound(all(vx), a[i].fi) - vx.begin(); a[i].se = upper_bound(all(vy), a[i].se) - vy.begin(); } sort(a + 1, a + n + 1); int m = sz(vy); SEGTREE st(m); for(int i = 1; i <= n; i++) { int pre = st.get(1, 1, m, a[i].se + 1, m); f[i] = f[pre] + 1; st.update(1, 1, m, a[i].se, i); } cout << f[n]; cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC; }

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

Main.cpp: In function 'int main()':
Main.cpp:52:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |                 freopen(task ".INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:53:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |                 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...