結果

問題 No.1675 Strange Minimum Query
ユーザー hiro71687khiro71687k
提出日時 2023-04-07 15:46:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 341 ms / 2,000 ms
コード長 1,527 bytes
コンパイル時間 4,275 ms
コンパイル使用メモリ 263,208 KB
実行使用メモリ 22,028 KB
最終ジャッジ日時 2024-04-10 16:17:37
合計ジャッジ時間 14,068 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 205 ms
12,012 KB
testcase_04 AC 182 ms
13,568 KB
testcase_05 AC 16 ms
7,808 KB
testcase_06 AC 243 ms
13,596 KB
testcase_07 AC 258 ms
16,164 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 121 ms
15,152 KB
testcase_11 AC 29 ms
11,648 KB
testcase_12 AC 132 ms
15,828 KB
testcase_13 AC 247 ms
22,028 KB
testcase_14 AC 289 ms
21,864 KB
testcase_15 AC 259 ms
21,968 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 48 ms
7,040 KB
testcase_18 AC 69 ms
7,808 KB
testcase_19 AC 92 ms
13,992 KB
testcase_20 AC 235 ms
17,752 KB
testcase_21 AC 187 ms
17,372 KB
testcase_22 AC 246 ms
19,180 KB
testcase_23 AC 202 ms
12,208 KB
testcase_24 AC 174 ms
13,312 KB
testcase_25 AC 135 ms
9,856 KB
testcase_26 AC 62 ms
9,344 KB
testcase_27 AC 164 ms
16,544 KB
testcase_28 AC 82 ms
13,572 KB
testcase_29 AC 55 ms
12,980 KB
testcase_30 AC 63 ms
9,216 KB
testcase_31 AC 266 ms
15,896 KB
testcase_32 AC 327 ms
21,868 KB
testcase_33 AC 326 ms
21,964 KB
testcase_34 AC 328 ms
22,028 KB
testcase_35 AC 318 ms
21,968 KB
testcase_36 AC 341 ms
21,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
using S = long long;
using F = long long;
ll inf=1000000000;
const S INF = inf;
const F ID = inf+1;
S op(S a, S b){ return std::min(a, b); }
S e(){ return INF; }
S mapping(F f, S x){ return (f == ID ? x : f); }
F composition(F f, F g){ return (f == ID ? g : f); }
F id(){ return ID; }
ld pie=3.141592653589793;
ll mod=1000000007;
int main(){
    ll n,q;
    cin >> n >> q;
    vector<ll>l(q),r(q),b(q);
    vector<pair<ll,pair<ll,ll>>>p(q);
    for (ll i = 0; i < q; i++)
    {
        cin >> l[i] >> r[i] >> b[i];
        l[i]--;
        p[i]={b[i],{l[i],r[i]}};
    }
    sort(p.begin(),p.end());
    vector<ll>v(n,inf);
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);
    for (ll i = 0; i < p.size(); i++)
    {
        seg.apply(p[i].second.first,p[i].second.second,p[i].first);
    }
    bool ok=true;
    for (ll i = 0; i < p.size(); i++)
    {
        ll x=seg.prod(p[i].second.first,p[i].second.second);
        if (x!=p[i].first)
        {
            ok=false;
            break;
        }
    }
    if (ok)
    {
        vector<ll>a(n);
        for (ll i = 0; i < n; i++)
        {
            a[i]=seg.get(i);
        }
        for (ll i = 0; i < n; i++)
        {
            cout << a[i];
            if (i<n-1)
            {
                cout << ' ';
            }
        }
        cout << endl;
    }else{
        cout << -1 << endl;
    }
    
}
0