結果
問題 | No.759 悪くない忘年会にしような! |
ユーザー |
|
提出日時 | 2018-12-07 01:16:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,855 bytes |
コンパイル時間 | 2,071 ms |
コンパイル使用メモリ | 206,140 KB |
最終ジャッジ日時 | 2025-01-06 18:32:48 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 WA * 30 |
ソースコード
#include <bits/stdc++.h>#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))#define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i))#define ALL(x) begin(x), end(x)using namespace std;template <class Monoid>struct segment_tree {typedef typename Monoid::underlying_type underlying_type;int n;vector<underlying_type> a;const Monoid mon;segment_tree() = default;segment_tree(int a_n, underlying_type initial_value = Monoid().unit(), Monoid const & a_mon = Monoid()) : mon(a_mon) {n = 1; while (n < a_n) n *= 2;a.resize(2 * n - 1, mon.unit());fill(a.begin() + (n - 1), a.begin() + ((n - 1) + a_n), initial_value); // set initial valuesREP_R (i, n - 1) a[i] = mon.append(a[2 * i + 1], a[2 * i + 2]); // propagate initial values}void point_set(int i, underlying_type z) { // 0-basedassert (0 <= i and i <= n);a[i + n - 1] = z;for (i = (i + n) / 2; i > 0; i /= 2) { // 1-baseda[i - 1] = mon.append(a[2 * i - 1], a[2 * i]);}}underlying_type range_concat(int l, int r) { // 0-based, [l, r)assert (0 <= l and l <= r and r <= n);underlying_type lacc = mon.unit(), racc = mon.unit();for (l += n, r += n; l < r; l /= 2, r /= 2) { // 1-based loop, 2x faster than recursionif (l % 2 == 1) lacc = mon.append(lacc, a[(l ++) - 1]);if (r % 2 == 1) racc = mon.append(a[(-- r) - 1], racc);}return mon.append(lacc, racc);}};struct max_monoid {typedef int underlying_type;int unit() const { return INT_MIN; }int append(int a, int b) const { return max(a, b); }};vector<int> solve(int n, vector<int> const & a, vector<int> const & b, vector<int> const & c) {vector<int> order(n);iota(ALL(order), 0);sort(ALL(order), [&](int i, int j) { return a[i] > a[j]; });vector<int> answer;int max_b = *max_element(ALL(b));segment_tree<max_monoid> segtree(max_b + 1);for (int l = 0; l < n; ) {int r = l + 1;while (r < n and a[order[r]] == a[order[l]]) ++ r;REP3 (m, l, r) {int i = order[m];if (segtree.range_concat(b[i], b[i] + 1) > c[i]) continue;if (segtree.range_concat(b[i] + 1, max_b + 1) >= c[i]) continue;answer.push_back(i);}REP3 (m, l, r) {int i = order[m];segtree.point_set(b[i], max(c[i], segtree.range_concat(b[i], b[i] + 1)));}l = r;}sort(ALL(answer));return answer;}int main() {int n; cin >> n;vector<int> a(n), b(n), c(n);REP (i, n) cin >> a[i] >> b[i] >> c[i];for (int i : solve(n, a, b, c)) {cout << i + 1 << endl;}return 0;}