結果

問題 No.1675 Strange Minimum Query
ユーザー yunix91201367yunix91201367
提出日時 2021-09-10 22:41:04
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 284 ms / 2,000 ms
コード長 1,825 bytes
コンパイル時間 1,978 ms
コンパイル使用メモリ 183,396 KB
実行使用メモリ 21,680 KB
最終ジャッジ日時 2023-09-02 19:35:49
合計ジャッジ時間 11,429 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 1 ms
4,368 KB
testcase_02 AC 1 ms
4,368 KB
testcase_03 AC 73 ms
11,904 KB
testcase_04 AC 64 ms
13,280 KB
testcase_05 AC 9 ms
7,452 KB
testcase_06 AC 86 ms
13,384 KB
testcase_07 AC 89 ms
16,052 KB
testcase_08 AC 1 ms
4,368 KB
testcase_09 AC 2 ms
4,372 KB
testcase_10 AC 100 ms
14,912 KB
testcase_11 AC 33 ms
11,360 KB
testcase_12 AC 110 ms
15,316 KB
testcase_13 AC 172 ms
21,512 KB
testcase_14 AC 212 ms
21,632 KB
testcase_15 AC 202 ms
21,656 KB
testcase_16 AC 2 ms
4,368 KB
testcase_17 AC 41 ms
6,812 KB
testcase_18 AC 58 ms
7,468 KB
testcase_19 AC 83 ms
13,740 KB
testcase_20 AC 182 ms
17,368 KB
testcase_21 AC 161 ms
17,020 KB
testcase_22 AC 214 ms
19,064 KB
testcase_23 AC 165 ms
11,892 KB
testcase_24 AC 150 ms
13,096 KB
testcase_25 AC 107 ms
9,664 KB
testcase_26 AC 55 ms
9,272 KB
testcase_27 AC 145 ms
16,372 KB
testcase_28 AC 77 ms
13,208 KB
testcase_29 AC 57 ms
12,816 KB
testcase_30 AC 53 ms
9,172 KB
testcase_31 AC 216 ms
15,704 KB
testcase_32 AC 282 ms
21,588 KB
testcase_33 AC 284 ms
21,676 KB
testcase_34 AC 282 ms
21,680 KB
testcase_35 AC 261 ms
21,672 KB
testcase_36 AC 261 ms
21,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/lazysegtree>
#define int long long
using namespace std;
using namespace atcoder;
using vec_int = vector<int>;
using vec_ii = vector<vec_int>;
using vec_iii = vector<vec_ii>;
using vec_iiii = vector<vec_iii>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
using ld = long double;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

void cout_line(vector<int> &a){
    for(int i=0;i<a.size();i++){
        if(i<a.size()-1){
            cout<<a.at(i)<<" ";
        }else{
            cout<<a.at(i)<<endl;
        }
    }
}

int op(int a, int b){
    return min(a, b);
}
int e() {
    return INT_MAX;
}
int mapping(int f, int x){
    return max(f, x);
}
int composition(int a, int b){
    return max(a, b);
}

int id(){
    return -1;
}




signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int N, Q; cin>>N>>Q;
    vec_int l(Q), r(Q), B(Q);
    rep(i, Q)cin>>l.at(i)>>r.at(i)>>B.at(i);
    vector<T> Qs(Q);
    rep(i, Q){
        Qs.at(i) = make_tuple(B.at(i), l.at(i), r.at(i));
    }
    sort(Qs.begin(), Qs.end());
    reverse(Qs.begin(), Qs.end());

    vec_int a(N, -1);
    lazy_segtree<int, op, e, int, mapping, composition, id> seg(a);

    rep(i, Q){
        int b, L, R; tie(b, L, R) = Qs.at(i);
        L--; R--;
        int temp = seg.prod(L, R+1);
        /*
        cout<<i<<" "<<L<<" "<<R<<" "<<temp<<endl;
        for(int j=0;j<5;j++){
            cout<<"i="<<i<<" j="<<j<<" "<<seg.get(j)<<endl;
        }
        */
        if(temp!=-1&&temp>b){
            cout<<-1<<endl;
            return 0;
        }
        seg.apply(L, R+1, b);
    }
    vec_int ans(N);
    rep(i,N){
        int num = seg.get(i);
        if(num==-1)num=4545;
        ans.at(i) = num;
    }
    cout_line(ans);






    return 0;
}
0