結果

問題 No.1675 Strange Minimum Query
ユーザー ripityripity
提出日時 2022-05-12 00:15:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 476 ms / 2,000 ms
コード長 1,436 bytes
コンパイル時間 5,735 ms
コンパイル使用メモリ 277,832 KB
実行使用メモリ 9,652 KB
最終ジャッジ日時 2023-09-26 16:10:24
合計ジャッジ時間 18,266 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 313 ms
5,600 KB
testcase_04 AC 293 ms
6,612 KB
testcase_05 AC 24 ms
5,212 KB
testcase_06 AC 370 ms
6,000 KB
testcase_07 AC 413 ms
7,448 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,384 KB
testcase_10 AC 179 ms
7,580 KB
testcase_11 AC 49 ms
6,700 KB
testcase_12 AC 196 ms
7,760 KB
testcase_13 AC 320 ms
9,168 KB
testcase_14 AC 409 ms
9,652 KB
testcase_15 AC 346 ms
9,124 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 66 ms
4,420 KB
testcase_18 AC 96 ms
4,636 KB
testcase_19 AC 135 ms
7,324 KB
testcase_20 AC 306 ms
8,076 KB
testcase_21 AC 271 ms
8,116 KB
testcase_22 AC 359 ms
8,788 KB
testcase_23 AC 279 ms
5,688 KB
testcase_24 AC 250 ms
6,384 KB
testcase_25 AC 180 ms
5,288 KB
testcase_26 AC 90 ms
5,416 KB
testcase_27 AC 238 ms
7,976 KB
testcase_28 AC 123 ms
7,140 KB
testcase_29 AC 88 ms
7,044 KB
testcase_30 AC 86 ms
5,488 KB
testcase_31 AC 366 ms
7,244 KB
testcase_32 AC 476 ms
9,224 KB
testcase_33 AC 470 ms
9,128 KB
testcase_34 AC 468 ms
9,240 KB
testcase_35 AC 453 ms
9,452 KB
testcase_36 AC 454 ms
9,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using namespace atcoder;
using namespace std;

struct S {int x;};
struct F {int y;};

constexpr int inf = 1000000000;
const F ID = F{-1};

S op(S l, S r) {
	return S{min(l.x, r.x)};
}

S e() {
	return S{inf};
}

S mapping(F f, S s) {
	if( f.y == ID.y ) return s;
	else return S{f.y};
}

F composition(F f, F g) {
	if( f.y == ID.y ) return F{g};
	else return F{f};
}

F id() {
	return ID;
}

int main() {
    
    int N, Q; cin >> N >> Q;
    bool ng = false;
    vector<S> v(N, S{inf});
    vector<tuple<int, int, int>> query(Q);
    for( int i = 0; i < Q; i++ ) {
        int l, r, b; cin >> l >> r >> b;
        query[i] = make_tuple(b, l, r);
    }
    
    sort(query.begin(), query.end());
    lazy_segtree<S, op, e, F, mapping, composition, id> ls(v);
    
    for( int i = 0; i < Q; i++ ) {
        int b, l, r;
        tie(b, l, r) = query[i];
        ls.apply(l-1, r, F{b});
    }
    
    for( int i = 0; i < Q; i++ ) {
        int b, l, r;
        tie(b, l, r) = query[i];
        S res = ls.prod(l-1, r);
        if( res.x != b ) ng = true;
    }
    
    if(ng) {
        cout << -1 << endl;
    }else {
        for( int i = 0; i < N; i++ ) {
            S res = ls.get(i);
            if( i > 0 ) cout << ' ';
            cout << res.x;
        }
        cout << endl;
    }
    
}
0