結果

問題 No.1675 Strange Minimum Query
ユーザー sten_sansten_san
提出日時 2021-09-10 21:59:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,892 bytes
コンパイル時間 5,114 ms
コンパイル使用メモリ 216,392 KB
実行使用メモリ 15,640 KB
最終ジャッジ日時 2023-09-02 17:30:09
合計ジャッジ時間 10,781 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 71 ms
6,212 KB
testcase_04 AC 79 ms
8,796 KB
testcase_05 AC 40 ms
8,980 KB
testcase_06 AC 82 ms
6,620 KB
testcase_07 AC 95 ms
8,732 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 137 ms
15,472 KB
testcase_14 AC 164 ms
15,472 KB
testcase_15 AC 156 ms
15,640 KB
testcase_16 AC 2 ms
4,368 KB
testcase_17 AC 31 ms
6,120 KB
testcase_18 AC 39 ms
6,492 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 138 ms
14,692 KB
testcase_23 AC 82 ms
8,100 KB
testcase_24 AC 93 ms
10,316 KB
testcase_25 AC 59 ms
7,112 KB
testcase_26 WA -
testcase_27 AC 115 ms
14,080 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 104 ms
8,804 KB
testcase_32 AC 169 ms
15,544 KB
testcase_33 AC 168 ms
15,464 KB
testcase_34 AC 167 ms
15,364 KB
testcase_35 AC 178 ms
15,564 KB
testcase_36 AC 180 ms
15,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

struct iofast_t {
    iofast_t() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} iofast;

struct uns_t {} uns;
template <typename Element, typename Head, typename ...Args>
auto vec(Element init, Head arg, Args ...args) {
    if constexpr (sizeof...(Args) == 0) return std::vector(arg, init);
    else return std::vector(arg, vec(init, args...));
}
template <typename Element, typename Head, typename ...Args>
auto vec(uns_t, Head arg, Args ...args) {
    return vec(Element(), arg, args...);
}

template <typename T, typename Compare = less<T>>
T &chmin(T &l, T r, Compare &&f = less<T>()) { return l = min(l, r, f); }
template <typename T, typename Compare = less<T>>
T &chmax(T &l, T r, Compare &&f = less<T>()) { return l = max(l, r, f); }

#include <atcoder/segtree>

constexpr int inf = INT_MAX / 2;

int op(int x, int y) {
    return min(x, y);
}

int elem() {
    return inf;
}

using segtree = atcoder::segtree<int, op, elem>;

int main() {
    int n, q; cin >> n >> q;
    auto query = vec<tuple<int, int, int>>(uns, q);
    for (auto &[l, r, b] : query) {
        cin >> l >> r >> b; --l;
    }

    sort(rbegin(query), rend(query), [](auto x, auto y) {
        return get<2>(x) < get<2>(y);
    });

    auto a = vec<int>(uns, n);

    set<int> rem;
    for (int i = 0; i < n; ++i) {
        rem.insert(i);
    }

    for (auto [l, r, b] : query) {
        auto iter = rem.lower_bound(l);
        auto last = rem.lower_bound(r);

        while (iter != last) {
            a[*iter] = b;
            iter = rem.erase(iter);
        }
    }

    segtree seg(a);
    for (auto [l, r, b] : query) {
        if (seg.prod(l, r) != b) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << a[0];
    for (int i = 1; i < n; ++i) {
        cout << ' ' << a[i];
    }
    cout << endl;
}

0