結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 313 ms
5,708 KB
testcase_04 AC 293 ms
6,528 KB
testcase_05 AC 23 ms
5,244 KB
testcase_06 AC 369 ms
5,936 KB
testcase_07 AC 412 ms
7,300 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 176 ms
7,580 KB
testcase_11 AC 49 ms
6,904 KB
testcase_12 AC 196 ms
7,972 KB
testcase_13 AC 320 ms
9,108 KB
testcase_14 AC 415 ms
9,108 KB
testcase_15 AC 350 ms
9,152 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 66 ms
4,416 KB
testcase_18 AC 97 ms
4,620 KB
testcase_19 AC 135 ms
7,328 KB
testcase_20 AC 305 ms
8,060 KB
testcase_21 AC 269 ms
8,180 KB
testcase_22 AC 357 ms
8,580 KB
testcase_23 AC 279 ms
5,856 KB
testcase_24 AC 250 ms
6,256 KB
testcase_25 AC 180 ms
5,144 KB
testcase_26 AC 88 ms
5,560 KB
testcase_27 AC 238 ms
7,948 KB
testcase_28 AC 123 ms
7,436 KB
testcase_29 AC 87 ms
7,108 KB
testcase_30 AC 85 ms
5,580 KB
testcase_31 AC 367 ms
7,008 KB
testcase_32 AC 475 ms
9,288 KB
testcase_33 AC 477 ms
9,164 KB
testcase_34 AC 468 ms
9,476 KB
testcase_35 AC 452 ms
9,360 KB
testcase_36 AC 453 ms
9,552 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{222};

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