結果

問題 No.1675 Strange Minimum Query
ユーザー hourenhouren
提出日時 2021-09-10 22:43:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,212 bytes
コンパイル時間 1,768 ms
コンパイル使用メモリ 181,696 KB
実行使用メモリ 15,240 KB
最終ジャッジ日時 2023-09-02 19:42:10
合計ジャッジ時間 6,787 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,372 KB
testcase_02 WA -
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,q;
    bool B = false;
    cin >> n >> q;
    vector<vector<P>> x(n+1);
    vector<int> ans(n);
    rep(i,q){
        int l,r,b;
        cin >> l >> r >> b;
        l--;
        x[l].push_back(make_pair(b,1));
        x[r].push_back(make_pair(b,0));
    }
    map<int,pair<int,bool>> mp;
    rep(i,n){
        for(auto now : x[i]){
            int y,z;
            tie(y,z) = now;
            if(z){
                mp[y].first++;
                mp[y].second = false;
            }
            else{
                if(!mp[y].second) B = true;
                mp[y].first--;
            }
            if(!mp[y].first) mp.erase(y);
        }
        if(mp.size()){
            auto it = max_element(all(mp));
            ans[i] = (*it).first;
            (*it).second.second = true;
        }
        else ans[i] = 1;
    }
    for(auto p : mp){
        if(!p.second.second) B = true;
    }
    if(B) cout << -1;
    else rep(i,n) cout << ans[i] << " ";
    cout << endl;
    return 0;
}
0