結果

問題 No.1675 Strange Minimum Query
ユーザー abc3abc3
提出日時 2021-09-10 23:57:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 261 ms / 2,000 ms
コード長 1,827 bytes
コンパイル時間 2,615 ms
コンパイル使用メモリ 217,216 KB
実行使用メモリ 24,256 KB
最終ジャッジ日時 2023-09-03 01:16:28
合計ジャッジ時間 12,255 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 112 ms
13,612 KB
testcase_04 AC 124 ms
14,916 KB
testcase_05 AC 57 ms
9,588 KB
testcase_06 AC 130 ms
15,496 KB
testcase_07 AC 148 ms
17,328 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 153 ms
14,344 KB
testcase_11 AC 67 ms
10,232 KB
testcase_12 AC 173 ms
15,972 KB
testcase_13 AC 226 ms
23,972 KB
testcase_14 AC 182 ms
24,164 KB
testcase_15 AC 177 ms
24,240 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 41 ms
7,216 KB
testcase_18 AC 53 ms
8,324 KB
testcase_19 AC 110 ms
14,344 KB
testcase_20 AC 155 ms
17,312 KB
testcase_21 AC 159 ms
18,084 KB
testcase_22 AC 198 ms
20,792 KB
testcase_23 AC 127 ms
13,792 KB
testcase_24 AC 133 ms
15,196 KB
testcase_25 AC 86 ms
10,712 KB
testcase_26 AC 59 ms
9,076 KB
testcase_27 AC 156 ms
17,904 KB
testcase_28 AC 92 ms
12,352 KB
testcase_29 AC 93 ms
12,868 KB
testcase_30 AC 61 ms
9,328 KB
testcase_31 AC 164 ms
16,648 KB
testcase_32 AC 249 ms
24,256 KB
testcase_33 AC 246 ms
24,160 KB
testcase_34 AC 246 ms
24,052 KB
testcase_35 AC 261 ms
24,152 KB
testcase_36 AC 261 ms
24,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

   #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    typedef unsigned long long ull;
    using P=pair<ll,ll>;
    const ll INF=1001001001;
    const int mod=1e9+7;

    void solve(){
        int n,Q;
        cin>>n>>Q;
        vector<vector<int>>t(Q,vector<int>(3));
        rep(i,Q){
            int l,r,b;
            cin>>l>>r>>b;
            l--;
            t[i]={b,l,r};
        }
        sort(t.rbegin(),t.rend());
        int pre=-1;
        set<int>used,unused;
        rep(i,n){unused.insert(i);}

        vector<int>ans(n,1e9);
        for(auto v:t){
            int b=v[0],l=v[1],r=v[2];
            if(b!=pre){
                pre=b;
                used.clear();
            }
            auto itr=unused.lower_bound(l);
            if(itr==unused.end()||*itr>=r){
                auto itr2=used.lower_bound(l);
                if(itr2==used.end()||*itr2>=r){
                    cout<<-1<<endl;
                    return;
                }
            }
            else{
                while(itr!=unused.end()&&*itr<r){
                    ans[*itr]=b;
                    used.insert(*itr);
                    itr=unused.erase(itr);
                }
            }
        }
        rep(i,n){
            if(i){cout<<" ";}
            cout<<ans[i];
        }
        cout<<endl;
    }
 
    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        solve(); 

        return 0;
    }
0