結果

問題 No.1675 Strange Minimum Query
ユーザー abc3abc3
提出日時 2021-09-10 23:18:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,684 bytes
コンパイル時間 2,879 ms
コンパイル使用メモリ 215,608 KB
実行使用メモリ 24,124 KB
最終ジャッジ日時 2023-09-02 21:43:40
合計ジャッジ時間 11,030 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 1 ms
4,368 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 97 ms
12,228 KB
testcase_04 AC 76 ms
10,708 KB
testcase_05 AC 6 ms
4,372 KB
testcase_06 AC 113 ms
13,736 KB
testcase_07 AC 120 ms
14,136 KB
testcase_08 AC 2 ms
4,368 KB
testcase_09 AC 2 ms
4,368 KB
testcase_10 AC 56 ms
8,660 KB
testcase_11 AC 15 ms
4,372 KB
testcase_12 AC 63 ms
9,740 KB
testcase_13 AC 129 ms
23,244 KB
testcase_14 AC 104 ms
19,364 KB
testcase_15 AC 130 ms
24,124 KB
testcase_16 AC 2 ms
4,368 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

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>>p(q,vector<int>(3));
        rep(i,q) {cin>>p[i][0]>>p[i][1]>>p[i][2];}
        
        sort(p.begin(),p.end());
        rep(i,q-1){
            if(p[i][0]==p[i+1][0]&&p[i][2]<p[i+1][2]){
                cout<<-1<<endl;
                return;
            }
        }
        priority_queue<P,vector<P>,greater<P>>pq;
        int pos=1;
        p.push_back({INF,INF,INF});
        vector<int>ans(n+1,1e9);
        for(auto u:p){
            int l=u[0],r=u[1],b=u[2];
            while(!pq.empty()&&pos<l){
                if(pq.top().first<pos){
                    cout<<-1<<endl;
                    return;
                }
                ans[pos]=pq.top().second;
                pq.pop();
                pos++;
            }
            pq.push({r,b});
            pos=l;
        }
        for(int i=1;i<=n;i++){
            if(i>1){cout<<" ";}
            cout<<ans[i];
        }
        cout<<endl;
    }
 
    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        solve(); 

        return 0;
    }
0