結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 70 ms
6,312 KB
testcase_04 AC 78 ms
8,892 KB
testcase_05 AC 41 ms
9,060 KB
testcase_06 AC 83 ms
6,708 KB
testcase_07 AC 95 ms
8,812 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,368 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 136 ms
15,420 KB
testcase_14 AC 165 ms
15,400 KB
testcase_15 WA -
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 AC 167 ms
15,412 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

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.upper_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