結果
問題 | No.759 悪くない忘年会にしような! |
ユーザー | kimiyuki |
提出日時 | 2018-12-07 01:16:05 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,855 bytes |
コンパイル時間 | 2,383 ms |
コンパイル使用メモリ | 212,772 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-14 03:06:08 |
合計ジャッジ時間 | 6,660 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | WA | - |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 2 ms
6,944 KB |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | WA | - |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 2 ms
6,940 KB |
testcase_18 | AC | 2 ms
6,944 KB |
testcase_19 | WA | - |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | AC | 1 ms
6,944 KB |
testcase_22 | AC | 2 ms
6,940 KB |
testcase_23 | AC | 2 ms
6,940 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 2 ms
6,944 KB |
testcase_27 | AC | 2 ms
6,940 KB |
testcase_28 | AC | 2 ms
6,944 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 2 ms
6,940 KB |
testcase_32 | AC | 2 ms
6,944 KB |
testcase_33 | AC | 10 ms
6,940 KB |
testcase_34 | AC | 3 ms
6,940 KB |
testcase_35 | AC | 7 ms
6,944 KB |
testcase_36 | WA | - |
testcase_37 | AC | 4 ms
6,940 KB |
testcase_38 | WA | - |
testcase_39 | AC | 4 ms
6,940 KB |
testcase_40 | WA | - |
testcase_41 | AC | 10 ms
6,940 KB |
testcase_42 | AC | 12 ms
6,940 KB |
testcase_43 | AC | 12 ms
6,940 KB |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | AC | 12 ms
6,940 KB |
testcase_51 | WA | - |
testcase_52 | AC | 12 ms
6,944 KB |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | AC | 87 ms
6,940 KB |
testcase_66 | WA | - |
ソースコード
#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 values REP_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-based assert (0 <= i and i <= n); a[i + n - 1] = z; for (i = (i + n) / 2; i > 0; i /= 2) { // 1-based a[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 recursion if (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; }