結果

問題 No.1675 Strange Minimum Query
ユーザー otoshigo
提出日時 2021-09-17 17:41:09
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 493 ms / 2,000 ms
コード長 1,637 bytes
コンパイル時間 4,477 ms
コンパイル使用メモリ 260,176 KB
最終ジャッジ日時 2025-01-24 14:27:02
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint1000000007;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;  using vvi = vector<vi>;
using vl = vector<ll>;   using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>;
using vm = vector<mint>; using vvm = vector<vm>;
using vpi = vector<pii>; using vvpi = vector<vpi>;
using vpl = vector<pll>; using vvpl = vector<vpl>;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
#define rep(i,m,n) for (int i = m; i < (int)(n); i++)
#define rrep(i,m,n) for (int i = m; i > (int)(n); i--)

using S = int;
using F = int;
S op(S a, S b){ return min(a, b); }
S e(){ return inf; }
S mapping(F f, S x){ return (f == inf ? x : f); }
F composition(F f, F g){ return (f == inf ? g : f);}
F id(){ return inf; }

int main(){
    int n,q; cin >> n >> q;
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(n);
    vvi vec;
    rep(_,0,q){
        int l,r,b; cin >> l >> r >> b; --l;
        vec.push_back({b,l,r});
    }
    sort(vec.begin(),vec.end());
    rep(i,0,q){
        int b = vec[i][0],l = vec[i][1],r = vec[i][2];
        seg.apply(l,r,b);
    }
    rep(i,0,q){
        int b = vec[i][0],l = vec[i][1],r = vec[i][2];
        if (seg.prod(l,r) != b){
            cout << -1 << endl;
            return 0;
        }
    }
    rep(i,0,n){
        if (seg.get(i) == inf) cout << 1;
        else cout << seg.get(i);
        if (i != n-1){
            cout << " ";
        }
    }
    cout << endl;
}
0