#include using namespace std; using ll = long long int; using ull = unsigned long long int; using P = pair; using P3 = pair; using PP = pair; constexpr int INF = 1 << 30; constexpr ll MOD = ll(1e9)+7; constexpr int di[] = {0, 1, 0, -1}; constexpr int dj[] = {1, 0, -1, 0}; constexpr double EPS = 1e-9; template struct SegmentTree{ private: using F = function; int N; vector node; F f; Monoid e; // identity element public: SegmentTree(){} SegmentTree(F f, Monoid e):f(f), e(e){} void init(int sz){ N = 1; while(N < sz) N <<= 1; node.assign(2*N-1, e); } void build(vector& v){ int sz = int(v.size()); init(sz); for(int i=0; i=0; i--){ node[i] = f(node[i*2+1], node[i*2+2]); } } void update(int k, Monoid x){ k += N-1; node[k] = x; while(k > 0){ k = (k-1)/2; node[k] = f(node[2*k+1], node[2*k+2]); } } // [a,b) Monoid query(int a, int b){return query(a, b, 0, 0, N);} Monoid query(int a, int b, int k, int l, int r){ if(b <= l || r <= a) return e; if(a <= l && r <= b) return node[k]; Monoid vl, vr; vl = query(a, b, 2*k+1, l, (l+r)/2); vr = query(a, b, 2*k+2, (l+r)/2, r); return f(vl, vr); } }; SegmentTree rmq([](ll a, ll b){return max(a,b);},0); int main(){ int N; cin >> N; vector

A(N); vector ord(N); vector B(N), C(N), rev(N); for(int i=0;i> A[i].first >> B[i] >> C[i]; A[i].second = i;; } sort(A.begin(), A.end()); vector r(N); // [0,r[i]) for(int i=0;i ban(N); int banmin = N+1; for(int i=0;i banmin){ ban[i] = true; } else if(r[i] <= i){ if(rmq.query(0,r[i]) > i){ ban[i] = true; banmin = min(banmin, i); } }else{ if(max(rmq.query(0,i), rmq.query(i+1,r[i])) > i){ ban[i] = true; banmin = min(banmin, i); } } } vector ans(N), tmp(N); rmq.init(N); // TODO ちゃんとトポソ順に更新する for(int i=0;i