結果

問題 No.759 悪くない忘年会にしような!
ユーザー gazellegazelle
提出日時 2018-12-07 00:12:13
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 209 ms / 2,000 ms
コード長 2,700 bytes
コンパイル時間 1,884 ms
コンパイル使用メモリ 139,512 KB
実行使用メモリ 9,428 KB
最終ジャッジ日時 2023-10-12 02:59:52
合計ジャッジ時間 7,832 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,496 KB
testcase_01 AC 3 ms
5,504 KB
testcase_02 AC 3 ms
5,452 KB
testcase_03 AC 3 ms
5,408 KB
testcase_04 AC 3 ms
5,480 KB
testcase_05 AC 3 ms
5,508 KB
testcase_06 AC 3 ms
5,568 KB
testcase_07 AC 3 ms
5,692 KB
testcase_08 AC 3 ms
5,500 KB
testcase_09 AC 3 ms
5,448 KB
testcase_10 AC 3 ms
5,456 KB
testcase_11 AC 3 ms
5,712 KB
testcase_12 AC 2 ms
5,492 KB
testcase_13 AC 2 ms
5,480 KB
testcase_14 AC 3 ms
5,440 KB
testcase_15 AC 2 ms
5,496 KB
testcase_16 AC 3 ms
5,584 KB
testcase_17 AC 3 ms
5,436 KB
testcase_18 AC 3 ms
5,588 KB
testcase_19 AC 3 ms
5,424 KB
testcase_20 AC 3 ms
5,452 KB
testcase_21 AC 3 ms
5,456 KB
testcase_22 AC 3 ms
5,500 KB
testcase_23 AC 3 ms
5,420 KB
testcase_24 AC 3 ms
5,496 KB
testcase_25 AC 3 ms
5,424 KB
testcase_26 AC 3 ms
5,556 KB
testcase_27 AC 3 ms
5,412 KB
testcase_28 AC 3 ms
5,452 KB
testcase_29 AC 3 ms
5,424 KB
testcase_30 AC 3 ms
5,420 KB
testcase_31 AC 3 ms
5,700 KB
testcase_32 AC 3 ms
5,524 KB
testcase_33 AC 9 ms
5,560 KB
testcase_34 AC 4 ms
5,744 KB
testcase_35 AC 6 ms
5,452 KB
testcase_36 AC 10 ms
5,512 KB
testcase_37 AC 4 ms
5,620 KB
testcase_38 AC 9 ms
5,456 KB
testcase_39 AC 4 ms
5,496 KB
testcase_40 AC 8 ms
5,516 KB
testcase_41 AC 9 ms
5,440 KB
testcase_42 AC 10 ms
5,596 KB
testcase_43 AC 11 ms
5,424 KB
testcase_44 AC 82 ms
8,384 KB
testcase_45 AC 81 ms
8,348 KB
testcase_46 AC 81 ms
8,264 KB
testcase_47 AC 82 ms
8,292 KB
testcase_48 AC 81 ms
8,288 KB
testcase_49 AC 10 ms
5,508 KB
testcase_50 AC 11 ms
5,564 KB
testcase_51 AC 11 ms
5,444 KB
testcase_52 AC 10 ms
5,612 KB
testcase_53 AC 81 ms
8,324 KB
testcase_54 AC 82 ms
8,252 KB
testcase_55 AC 81 ms
8,264 KB
testcase_56 AC 81 ms
8,196 KB
testcase_57 AC 80 ms
8,356 KB
testcase_58 AC 80 ms
8,200 KB
testcase_59 AC 79 ms
8,324 KB
testcase_60 AC 81 ms
8,276 KB
testcase_61 AC 81 ms
8,320 KB
testcase_62 AC 81 ms
8,336 KB
testcase_63 AC 209 ms
9,260 KB
testcase_64 AC 209 ms
9,420 KB
testcase_65 AC 74 ms
8,272 KB
testcase_66 AC 199 ms
9,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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_back

constexpr 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;
}

/* --------------------------------------- */

0