結果

問題 No.1675 Strange Minimum Query
ユーザー siro53siro53
提出日時 2021-09-10 21:59:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,950 bytes
コンパイル時間 2,666 ms
コンパイル使用メモリ 212,080 KB
実行使用メモリ 17,084 KB
最終ジャッジ日時 2023-09-02 17:31:03
合計ジャッジ時間 8,583 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 69 ms
6,564 KB
testcase_04 AC 75 ms
9,740 KB
testcase_05 AC 38 ms
9,552 KB
testcase_06 AC 79 ms
6,988 KB
testcase_07 AC 93 ms
9,548 KB
testcase_08 AC 1 ms
4,368 KB
testcase_09 AC 2 ms
4,372 KB
testcase_10 AC 119 ms
12,936 KB
testcase_11 AC 54 ms
11,712 KB
testcase_12 AC 137 ms
14,060 KB
testcase_13 RE -
testcase_14 AC 167 ms
17,084 KB
testcase_15 WA -
testcase_16 AC 2 ms
4,496 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 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define FOR(i, a, b) for(int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

void Case(int i) { cout << "Case #" << i << ": "; }
int popcount(int x) { return __builtin_popcount(x); }
ll popcount(ll x) { return __builtin_popcountll(x); }
#pragma endregion Macros

#include <atcoder/segtree>
int op(int a, int b) { return min(a, b); }
const int MAX = 1000000000;
int e() { return MAX; }
using segtree = atcoder::segtree<int, op, e>;

struct Data {
    int l, r, B;
};

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<Data> qs(Q);
    REP(i, Q) {
        int l, r, B;
        cin >> l >> r >> B;
        l--;
        qs[i] = {l, r, B};
    }
    sort(ALL(qs), [](const Data& l, const Data& r) {
        if(l.B != r.B) return (l.B < r.B);
        else if(l.r != r.r) return (l.r < r.r);
        else return (l.l < r.r);
    });

    segtree seg(N);
    set<int> se;
    REP(i, N) se.insert(i);

    REP(i, Q) {
        auto [l, r, B] = qs[i];
        int mn = seg.prod(l, r);
        if(mn < B) {
            cout << "-1\n";
            return 0;
        } else if(mn == B) {
            continue;
        }
        auto it = se.lower_bound(l);
        int id = (*it);
        debug(l, r, B, id);
        if(id >= r) {
            cout << "-1\n";
            return 0;
        }
        seg.set(id, B);
        se.erase(it);
    }
    REP(i, N) cout << seg.get(i) << " \n"[i == N-1];
}
0