結果

問題 No.1675 Strange Minimum Query
ユーザー yakkiyakki
提出日時 2021-09-10 22:14:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,109 bytes
コンパイル時間 1,435 ms
コンパイル使用メモリ 135,228 KB
実行使用メモリ 28,200 KB
最終ジャッジ日時 2023-09-02 18:11:42
合計ジャッジ時間 11,369 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,368 KB
testcase_02 WA -
testcase_03 AC 219 ms
16,860 KB
testcase_04 AC 204 ms
17,832 KB
testcase_05 AC 48 ms
9,572 KB
testcase_06 AC 261 ms
19,184 KB
testcase_07 AC 276 ms
21,240 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
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<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<ctime>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0)

const double EPS = 1e-18;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
//using mint = modint998244353;

int dh[] = {-1,1,0,0};
int dw[] = {0,0,1,-1};

template<typename T>
vector<T> compress(vector<T> &v){
    vector<T> res = v;
    sort(res.begin(),res.end());
    res.erase(unique(res.begin(),res.end()),res.end());
    for(auto &u : v){u = lower_bound(res.begin(),res.end(),u)-res.begin();}
    return res;
}


int main(){
    int n,q; cin >> n >> q;
    vector<int> l(q),r(q),c(q);
    rep(i,q){
        cin >> l[i] >> r[i] >> c[i];
        l[i]--;
        r[i]--;
    }
    vector<int> b = c;
    compress(b);
    vector<int> re(q);
    rep(i,q) re[b[i]] = c[i];
    vector<vector<Pi>> que(q);
    rep(i,q){
        que[b[i]].push_back({l[i],r[i]});
    }
    vector<int> ans(n,1000000000);
    set<int> st;
    rep(i,n) st.insert(i);
    for(int i = q-1; i >= 0; i--){
        for(auto [l2,r2] : que[i]){
            auto p = st.lower_bound(l2);
            auto p2 = st.lower_bound(r2+1);
            if(p == p2){
                cout << -1 << endl;
                return 0;
            }
        }
        for(auto [l2,r2] : que[i]){
            auto p = st.lower_bound(l2);
            auto p2 = st.lower_bound(r2+1);
            if(p == p2) continue;
            ans[*p] = re[i];
            while(p != p2){
                p = st.erase(p);
            }
        }
    }
    rep(i,n){
        cout << ans[i] << " ";
    }
    cout << endl;
}
0