#include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,n,s) for(int i = (s); i < int(n); i++) #define MM << " " << #define all(x) x.begin(), x.end() template using MinHeap = std::priority_queue, std::greater>; using ll = long long; using Pii = std::pair; using Pll = std::pair; template bool chmin(T& a, const T b) { if(a > b) { a = b; return true; } else { return false; } } template bool chmax(T& a, const T b) { if(a < b) { a = b; return true; } else { return false; } } template void vdeb(std::vector &da) { auto n = da.size(); for(size_t i = 0; i < n; i++) { if(i == n-1) std::cout << da[i] << std::endl; else std::cout << da[i] << " "; } } template<> void vdeb(std::vector &da) { auto n = da.size(); for(size_t i = 0; i < n; i++) { std::cout << da[i] << std::endl; } } template struct SegTree{ std::vector nod; T t0; std::function operation; std::function merge; int size; SegTree(int _size, T _t0, std::function _operation, std::function _merge):t0(_t0), operation(_operation), merge(_merge){ size=1; while(_size>size){ size*=2; } nod=std::vector(size*2-1, t0); } void update(int k, T a){ // operation(da[k], a) assert(0<= k && k < size); k+=size-1; nod[k] = operation(nod[k], a); while(k>0){ k=(k-1)/2; nod[k] = merge(nod[k*2+1], nod[k*2+2]); } } void range_update(int a, int b, T x) { assert(0 <= a && a < size); assert(0 <= b && b <= size); assert(a <= b); range_update_query(a, b, 0, 0, size, x); } T sum(int a, int b) { // merge[a, b) assert(0 <= a && a < size); assert(0 <= b && b <= size); assert(a <= b); return sum_query(a, b, 0, 0, size); } void deb(){ for(int i=0;i> n >> q; vector> da(n+1); vector> query(q); rep(i,q,0) { int l, r, b; cin >> l >> r >> b; da[l-1].push_back({b, 0}); da[r].push_back({b, 1}); query[i] = {{l-1, r}, b}; } SegTree st(n, 1000000000, [](int x, int y){return min(x, y);}, [](int x, int y){return min(x, y);}); map mp; rep(i,n,0) { for(auto &j : da[i]) { if(j.second) { mp[j.first]--; if(mp[j.first] == 0) mp.erase(j.first); } else { mp[j.first]++; } } if(!mp.empty()) st.update(i, (--mp.end())->first); } rep(i,q,0) { if(st.sum(query[i].first.first, query[i].first.second) != query[i].second) { cout << -1 << endl; return 0; } } vector ans(n); rep(i,n,0) ans[i] = st.sum(i, i+1); vdeb(ans); }