結果
問題 | No.759 悪くない忘年会にしような! |
ユーザー |
![]() |
提出日時 | 2018-12-07 00:12:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 224 ms / 2,000 ms |
コード長 | 2,700 bytes |
コンパイル時間 | 1,780 ms |
コンパイル使用メモリ | 136,548 KB |
最終ジャッジ日時 | 2025-01-06 18:30:47 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 64 |
ソースコード
#include<iostream>#include<vector>#include<algorithm>#include<set>#include<map>#include<unordered_map>#include<queue>#include<iomanip>#include<math.h>#include<bitset>#include<cassert>#include<random>#include<time.h>#include<functional>using namespace std;using ll=long long;using ld=long double;using P=pair<ll,ll>;#define MOD 1000000007LL#define INF 1000000000LL#define EPS 1e-10#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)#define REP(i,n) FOR(i,0,n)#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}#define ALL(v) v.begin(),v.end()#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());#define pb push_backconstexpr int MAX_SIZE = 303030;template <typename T>class SegTree {private:int n;const function<T(T, T)> op; // 演算const T ie; // 演算の単位元T seq[MAX_SIZE];public:/// op: 演算, ie: 演算の単位元SegTree(int _n, function<T(T, T)> op, const T ie) : op(op), ie(ie) {n = 1;while(n < _n) n *= 2;for(int i = 0; i < 2 * n - 1; i++) seq[i] = ie;}/// k 番目(0-indexed)の要素を e で更新void update(int k, const T e) {k += n - 1;seq[k] = e;while(k > 0) {k = (k - 1) / 2;seq[k] = op(seq[k * 2 + 1], seq[k * 2 + 2]);}}// k 番目(0-indexed)の要素を取得T get(int k) {k += n - 1;return seq[k];}/// [a, b) 番目(0-indexed)の要素全体の演算結果を返すT query(int a, int b, int k = 0, int l = 0, int r = -1) {if(r == -1) r = n;if(r <= a || b <= l) return ie;if(a <= l && r <= b) return seq[k];T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);return op(vl, vr);}};// [Range Sum Query] op: [] (long long a, long long b) { return a + b; }, ie: 0// [Range Maximum Query] op: [] (long long a, long long b) { return max(a, b); }, ie: -1e18// [Range Minimum Query] op: [] (long long a, long long b) { return min(a, b); }, ie: 1e18/* --------------------------------------- */int main() {cin.tie(0);ios::sync_with_stdio(false);ll n;cin >> n;vector<pair<P,P>> g(n);REP(i, n) {cin >> g[i].first.first >> g[i].first.second>> g[i].second.first;g[i].second.second = i;}sort(ALL(g));SegTree<ll> segtree(100010, [] (ll a, ll b) { return max(a, b); }, -1e18);vector<ll> ans;for(ll i = n - 1; i >= 0; i--) {if(segtree.query(g[i].first.second, 100010) < g[i].second.first) {ans.pb(g[i].second.second);}segtree.update(g[i].first.second, max(segtree.get(g[i].first.second), g[i].second.first));}sort(ALL(ans));REP(i, ans.size()) cout << ans[i] + 1 << endl;return 0;}/* --------------------------------------- */