#include using namespace std; #define rep(i,n) for(long long i = 0; i < (long long)(n); i++) #define pb push_back #define all(x) (x).begin(), (x).end() #define fi first #define se second template bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); } template bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } using ll = long long; using vll = vector; using vvll = vector; using P = pair; struct Pool { int pos; char mem[(ll)2e8]; // 200MB Pool(){ free(); } template T *fetch(size_t n = 1) { T *res = (T*)(mem + pos); pos += sizeof(T)*n; return res; } void free(){ pos = 0; } }; Pool pool; template class AssosiativeOperator { public: AssosiativeOperator(void) { } T T0; virtual T op(T a, T b) = 0; T L0; virtual T op_lazy(T a, T b) = 0; virtual T resolve_lazy(T d, T l, int nl, int nr) = 0; }; template class AssosiativeOperatorMax : public AssosiativeOperator { public: AssosiativeOperatorMax(void) { AssosiativeOperator::T0 = -100; AssosiativeOperator::L0 = 0; } virtual T op(T a, T b) { return max(a, b); } // Range Max virtual T op_lazy(T a, T b) { return max(a, b); } // Range Add virtual T resolve_lazy(T d, T l, int nl, int nr) { return max(d, l); } // 全部上がってるので、子によらず増える }; template class SegmentTree { public: T *dat, *lazy; AssosiativeOperator* op; int n = 1; int bits = 0; const size_t size_; int ql, qr; bool enable_range_update_flag = true; bool enable_point_update_with_op_flag = false; SegmentTree(int n_, AssosiativeOperator* op) : size_(n_) { this->op = op; while(n < n_) { n <<= 1; bits++; } dat = pool.fetch(n+n); lazy = pool.fetch(n+n); fill_n(dat, n*4, this->op->T0); } void inline pushdown(int v, int nl, int nr){ assert(enable_range_update_flag); dat[v] = op->resolve_lazy(dat[v], lazy[v], nl, nr); if(v < n){ // 子がいれば lazy[v<<1] = op->op_lazy(lazy[v<<1], lazy[v]); lazy[v<<1|1] = op->op_lazy(lazy[v<<1|1], lazy[v]); } lazy[v] = op->L0; } void inline pullup(int v){ assert(enable_range_update_flag); dat[v] = op->op(dat[v<<1], dat[v<<1|1]); } void update(int v, const T &x){ v += n; if (enable_point_update_with_op_flag) dat[v] = op->op(dat[v], x); else dat[v] = x; while (v){ v = v >> 1; dat[v] = op->op(dat[v<<1], dat[v<<1|1]); } } void update(int n, int nl, int nr, const T &x){ assert(enable_range_update_flag); pushdown(n, nl, nr); if(nr <= ql || qr <= nl) return; if(ql <= nl && nr <= qr) { lazy[n] = op->op_lazy(lazy[n], x); pushdown(n, nl, nr); return; } int m = (nl + nr) / 2; update(n<<1, nl, m, x); update(n<<1|1, m, nr, x); pullup(n); } void update(int l, int r, const T &x){ ql = l; qr = r; return update(1, 0, n, x); } T query(int n, int nl, int nr){ if (enable_range_update_flag) pushdown(n, nl, nr); if(nr <= ql || qr <= nl) return op->T0; if(ql <= nl && nr <= qr) return dat[n]; if (enable_range_update_flag) pullup(n); int m = (nl + nr) / 2; return op->op(query(n<<1, nl, m), query(n<<1|1, m, nr)); } T query(int l, int r){ ql = l; qr = r; return query(1, 0, n); } }; int main(void) { ios::sync_with_stdio(false); cin.tie(0); SegmentTree s(2e5, new AssosiativeOperatorMax()); ll n; cin >> n; assert(0 <= n && n <= 1e4); vector> g(2e5); map memo; rep(i, n) { ll x, y, z; cin >> x >> y >> z; assert(0 <= x && x <= 1e4); assert(0 <= y && y <= 1e4); assert(0 <= z && z <= 1e4); g[x].pb(P(y, z + 1)); memo[{x, y, z + 1}] = i; } assert(memo.size() == n); vector ret; for (ll i = g.size() - 1; i >= 0; i--) { sort(all(g[i])); reverse(all(g[i])); vector

next; for (auto x : g[i]) { if (x.se > s.query(x.fi, x.fi+1)) { next.pb(x); ret.pb({i, x.fi, x.se}); } s.update(0, x.fi+1, x.se); } } set id; for (auto x : ret) { id.insert(memo[x]); } for (auto x : id) { cout << x + 1 << endl; } return 0; }