結果
問題 | No.759 悪くない忘年会にしような! |
ユーザー |
![]() |
提出日時 | 2018-12-07 00:42:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 113 ms / 2,000 ms |
コード長 | 1,529 bytes |
コンパイル時間 | 2,104 ms |
コンパイル使用メモリ | 206,972 KB |
最終ジャッジ日時 | 2025-01-06 18:31:16 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 64 |
ソースコード
#include<bits/stdc++.h> using namespace std; using P = pair<int, int>; const int M = 1000000007; class max_segtree { private: int n, s, t; vector<int> tr; const int ex = -1; int q(int k, int l, int r) { return r <= s || t <= l ? ex : s <= l && r <= t ? tr[k] : max(q(k << 1 | 1, l, (l + r) >> 1), q((k + 1) << 1, (l + r) >> 1, r)); } public: max_segtree(int m) { n = 1; while (n < m) n <<= 1; tr.clear(); tr.resize((n << 1) - 1, ex); } void update(int j, const int& x) { int i = j + n - 1; tr[i] = x; while (i > 0) { i = (i - 1) >> 1; tr[i] = max(tr[i << 1 | 1], tr[(i + 1) << 1]); } } int look(int j) { return tr[j + n - 1]; } // [s, t) int run(int _s, int _t) { s = _s; t = _t; return q(0, 0, n); } }; int main() { int n; cin >> n; vector<pair<int, pair<P, int>>> a(n); for (int i = 0; i < n; ++i) { cin >> a[i].first >> a[i].second.first.first >> a[i].second.first.second; a[i].second.second = i; } sort(a.begin(), a.end()); reverse(a.begin(), a.end()); max_segtree sg(10010); vector<bool> ans(n, true); for (auto& i : a) { P& p = i.second.first; if (sg.run(p.first, 10010) >= p.second) ans[i.second.second] = false; if (sg.look(p.first) < p.second) sg.update(p.first, p.second); } for (int i = 0; i < n; ++i) if (ans[i]) cout << i + 1 << "\n"; return 0; }