結果

問題 No.1675 Strange Minimum Query
ユーザー みここみここ
提出日時 2021-09-10 22:01:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 351 ms / 2,000 ms
コード長 1,187 bytes
コンパイル時間 866 ms
コンパイル使用メモリ 83,000 KB
実行使用メモリ 9,672 KB
最終ジャッジ日時 2023-09-02 17:37:14
合計ジャッジ時間 11,962 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,700 KB
testcase_01 AC 2 ms
5,720 KB
testcase_02 AC 3 ms
5,772 KB
testcase_03 AC 214 ms
5,960 KB
testcase_04 AC 191 ms
7,348 KB
testcase_05 AC 17 ms
7,396 KB
testcase_06 AC 261 ms
5,964 KB
testcase_07 AC 262 ms
7,332 KB
testcase_08 AC 4 ms
5,992 KB
testcase_09 AC 3 ms
5,788 KB
testcase_10 AC 128 ms
9,176 KB
testcase_11 AC 36 ms
8,812 KB
testcase_12 AC 138 ms
9,076 KB
testcase_13 AC 266 ms
9,432 KB
testcase_14 AC 305 ms
9,124 KB
testcase_15 AC 278 ms
9,672 KB
testcase_16 AC 3 ms
5,848 KB
testcase_17 AC 49 ms
6,484 KB
testcase_18 AC 72 ms
6,412 KB
testcase_19 AC 99 ms
9,132 KB
testcase_20 AC 229 ms
9,188 KB
testcase_21 AC 201 ms
9,188 KB
testcase_22 AC 259 ms
9,260 KB
testcase_23 AC 221 ms
6,548 KB
testcase_24 AC 190 ms
7,268 KB
testcase_25 AC 142 ms
6,796 KB
testcase_26 AC 69 ms
7,336 KB
testcase_27 AC 178 ms
9,184 KB
testcase_28 AC 92 ms
9,260 KB
testcase_29 AC 64 ms
9,184 KB
testcase_30 AC 64 ms
7,340 KB
testcase_31 AC 284 ms
7,224 KB
testcase_32 AC 351 ms
9,252 KB
testcase_33 AC 346 ms
9,068 KB
testcase_34 AC 351 ms
9,076 KB
testcase_35 AC 341 ms
9,196 KB
testcase_36 AC 335 ms
9,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/lazysegtree>
#include <algorithm>
#include <iostream>
using namespace std;
using namespace atcoder;
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int INF = 1000000000;

struct S
{
    int x;
};

S op(S a, S b){
    return S{min(a.x, b.x)};
}

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

struct F
{
    int f;
};

S mapping(F f, S a){
    if(f.f == 0) return a;
    return S{f.f};
}

F composition(F f, F g){
    if(f.f == 0) return g;
    return f;
}

F id(){
    return F{0};
}

int main()
{
    int n, q;
    cin >> n >> q;
    PP p[200005];
    for(int i = 0; i < q; i++){
        int l, r, b;
        cin >> l >> r >> b;
        l--;
        p[i] = PP(b, P(l, r));
    }
    sort(p, p + q);
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(n);
    for(int i = 0; i < q; i++){
        seg.apply(p[i].second.first, p[i].second.second, F{p[i].first});
    }
    for(int i = 0; i < q; i++){
        if(seg.prod(p[i].second.first, p[i].second.second).x != p[i].first){
            cout << -1 << endl;
            return 0;
        }
    }
    for(int i = 0; i < n; i++){
        cout << seg.get(i).x;
        if(i < n - 1) cout << " ";
    }
    cout << endl;
}
0