結果

問題 No.1675 Strange Minimum Query
ユーザー wait_sushiwait_sushi
提出日時 2021-09-10 21:33:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 9,375 bytes
コンパイル時間 3,999 ms
コンパイル使用メモリ 229,364 KB
実行使用メモリ 32,248 KB
最終ジャッジ日時 2023-09-02 16:05:54
合計ジャッジ時間 11,502 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 7 ms
15,116 KB
testcase_02 WA -
testcase_03 AC 140 ms
22,344 KB
testcase_04 AC 127 ms
25,084 KB
testcase_05 AC 19 ms
19,392 KB
testcase_06 AC 162 ms
22,600 KB
testcase_07 AC 175 ms
24,936 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 <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
#pragma comment(linker, "/stack:200000000")
#define overload4(_1, _2, _3, _4, name, ...) name
#define overload3(_1, _2, _3, name, ...) name
#define rep1(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for (ll i = n; i--;)
#define rrep2(i, n) for (ll i = n; i--;)
#define rrep3(i, a, b) for (ll i = b; i-- > (a);)
#define rrep4(i, a, b, c)                                                      \
  for (ll i = (a) + ((b) - (a)-1) / (c) * (c); i >= (a); i -= c)
#define rrep(...)                                                              \
  overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define elif else if
ll beki(ll i) { return 1ll << i; }
#define skip(M)                                                                \
  if (M)                                                                       \
  continue
#define all(v) v.begin(), v.end()
#define allm(x, y, M) for (auto [(x), (y)] : (M))
#define alls(i, S) for (auto(&i) : (S))
#define pb push_back
#define fi first
#define se second
const ll INF = (1LL << 61) - 1;
const ll mod = 1000000007;
// const ll mod = 998244353;
const ll MAX_N1 = 200010;
const ll MAX_N2 = 500010;
template <class X> void print(X x) { cout << x << endl; }
void print(vl x) {
  for (ll i : x) {
    cout << i << " ";
  }
  cout << endl;
}
void print(vector<PP> x) {
  for (PP i : x) {
    cout << i.first << " " << i.second << endl;
  }
  cout << endl;
}
template <class X> void printr(X x) { cerr << x << endl; }
void printr(vl x) {
  for (ll i : x) {
    cerr << i << " ";
  }
  cerr << endl;
}
void printr(vector<PP> x) {
  for (PP i : x) {
    cerr << i.first << " " << i.second << endl;
  }
  cout << endl;
}
template <class X> int lbound(vector<X> &Y, X a) {
  return lower_bound(all(Y), a) - Y.begin();
}
template <class X> int ubound(vector<X> &Y, X a) {
  return upper_bound(all(Y), a) - Y.begin();
}
template <class X> X lbound2(vector<X> &Y, X a, int mode = 0) {
  int x = lbound(Y, a) - mode;
  if (x < 0 || x >= Y.size())
    return INF;
  return Y[x];
}
template <class X> X ubound2(vector<X> &Y, X a, int mode = 0) {
  int x = ubound(Y, a) - mode;
  if (x < 0 || x >= Y.size())
    return INF;
  return Y[x];
}
template <class... T> void cl(T &... t) { (..., (t.clear())); }
template <class... T> void in(T &... t) { (..., (cin >> t)); }
template <class... T> void put(vl &V, int n, int mode = 0) {
  ll k;
  if (mode == 0)
    cl(V);
  rep(i, n) {
    cin >> k;
    V.pb(k);
  }
}
int max_index(vl &V) { return max_element(all(V)) - V.begin(); }
int min_index(vl &V) { return min_element(all(V)) - V.begin(); }
ll sum(vl &V) { return accumulate(all(V), 0ll); }
template <typename T> void UNIQUE(vector<T> &v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
}
template <typename T> T ADD(T a, T b) {
  T res;
  return __builtin_add_overflow(a, b, &res) ? numeric_limits<T>::max() : res;
}
template <typename T> T MUL(T a, T b) {
  T res;
  return __builtin_mul_overflow(a, b, &res) ? numeric_limits<T>::max() : res;
};
template <typename T> T POW(T a, int n) {
  T res = 1;
  for (; n > 0; n >>= 1, a *= a)
    if (n & 1)
      res *= a;
  return res;
}
template <class X> bool ma(X &a, X b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class X> bool mi(X &a, X b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
void vset(vl &A, ll n, ll k) { A = vl(n, k); }
void so(vl &A) { sort(all(A)); }
ll age(ll x, ll y) { return (x + y - 1) / y; }
ll a, b, c, d, aa, bb, cc, dd, h, x, y, z, p, q, n, t, r, k, w, l, ans, m, u, v;
ll codeforces = 1;
string S, T, U;
vl A, B, C, D;
vl g[MAX_N2];
vector<PP> VP, VP2;
set<ll> s1, s2;
int ceil_pow2(int n) {
  int x = 0;
  while ((1U << x) < (unsigned int)(n))
    x++;
  return x;
}

namespace atcoder {

template <class S, S (*op)(S, S), S (*e)(), class F, S (*mapping)(F, S),
          F (*composition)(F, F), F (*id)()>
struct lazy_segtree {
public:
  lazy_segtree() : lazy_segtree(0) {}
  lazy_segtree(int n) : lazy_segtree(std::vector<S>(n, e())) {}
  lazy_segtree(const std::vector<S> &v) : _n(int(v.size())) {
    log = ceil_pow2(_n);
    size = 1 << log;
    d = std::vector<S>(2 * size, e());
    lz = std::vector<F>(size, id());
    for (int i = 0; i < _n; i++)
      d[size + i] = v[i];
    for (int i = size - 1; i >= 1; i--) {
      update(i);
    }
  }

  void set(int p, S x) {
    assert(0 <= p && p < _n);
    p += size;
    for (int i = log; i >= 1; i--)
      push(p >> i);
    d[p] = x;
    for (int i = 1; i <= log; i++)
      update(p >> i);
  }

  S get(int p) {
    assert(0 <= p && p < _n);
    p += size;
    for (int i = log; i >= 1; i--)
      push(p >> i);
    return d[p];
  }

  S prod(int l, int r) {
    assert(0 <= l && l <= r && r <= _n);
    if (l == r)
      return e();

    l += size;
    r += size;

    for (int i = log; i >= 1; i--) {
      if (((l >> i) << i) != l)
        push(l >> i);
      if (((r >> i) << i) != r)
        push(r >> i);
    }

    S sml = e(), smr = e();
    while (l < r) {
      if (l & 1)
        sml = op(sml, d[l++]);
      if (r & 1)
        smr = op(d[--r], smr);
      l >>= 1;
      r >>= 1;
    }

    return op(sml, smr);
  }

  S all_prod() { return d[1]; }

  void apply(int p, F f) {
    assert(0 <= p && p < _n);
    p += size;
    for (int i = log; i >= 1; i--)
      push(p >> i);
    d[p] = mapping(f, d[p]);
    for (int i = 1; i <= log; i++)
      update(p >> i);
  }
  void apply(int l, int r, F f) {
    assert(0 <= l && l <= r && r <= _n);
    if (l == r)
      return;

    l += size;
    r += size;

    for (int i = log; i >= 1; i--) {
      if (((l >> i) << i) != l)
        push(l >> i);
      if (((r >> i) << i) != r)
        push((r - 1) >> i);
    }

    {
      int l2 = l, r2 = r;
      while (l < r) {
        if (l & 1)
          all_apply(l++, f);
        if (r & 1)
          all_apply(--r, f);
        l >>= 1;
        r >>= 1;
      }
      l = l2;
      r = r2;
    }

    for (int i = 1; i <= log; i++) {
      if (((l >> i) << i) != l)
        update(l >> i);
      if (((r >> i) << i) != r)
        update((r - 1) >> i);
    }
  }

  template <bool (*g)(S)> int max_right(int l) {
    return max_right(l, [](S x) { return g(x); });
  }
  template <class G> int max_right(int l, G g) {
    assert(0 <= l && l <= _n);
    assert(g(e()));
    if (l == _n)
      return _n;
    l += size;
    for (int i = log; i >= 1; i--)
      push(l >> i);
    S sm = e();
    do {
      while (l % 2 == 0)
        l >>= 1;
      if (!g(op(sm, d[l]))) {
        while (l < size) {
          push(l);
          l = (2 * l);
          if (g(op(sm, d[l]))) {
            sm = op(sm, d[l]);
            l++;
          }
        }
        return l - size;
      }
      sm = op(sm, d[l]);
      l++;
    } while ((l & -l) != l);
    return _n;
  }

  template <bool (*g)(S)> int min_left(int r) {
    return min_left(r, [](S x) { return g(x); });
  }
  template <class G> int min_left(int r, G g) {
    assert(0 <= r && r <= _n);
    assert(g(e()));
    if (r == 0)
      return 0;
    r += size;
    for (int i = log; i >= 1; i--)
      push((r - 1) >> i);
    S sm = e();
    do {
      r--;
      while (r > 1 && (r % 2))
        r >>= 1;
      if (!g(op(d[r], sm))) {
        while (r < size) {
          push(r);
          r = (2 * r + 1);
          if (g(op(d[r], sm))) {
            sm = op(d[r], sm);
            r--;
          }
        }
        return r + 1 - size;
      }
      sm = op(d[r], sm);
    } while ((r & -r) != r);
    return 0;
  }

private:
  int _n, size, log;
  std::vector<S> d;
  std::vector<F> lz;

  void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }
  void all_apply(int k, F f) {
    d[k] = mapping(f, d[k]);
    if (k < size)
      lz[k] = composition(f, lz[k]);
  }
  void push(int k) {
    all_apply(2 * k, lz[k]);
    all_apply(2 * k + 1, lz[k]);
    lz[k] = id();
  }
};

} // namespace atcoder

using SS = long long;
using FF = long long;

const FF ID = 8e18;

SS op(SS a, SS b) { return std::min(a, b); }
SS e() { return INF; }
SS mapping(FF f, SS x) { return (f == ID ? x : f); }
FF composition(FF f, FF g) { return (f == ID ? g : f); }
FF id() { return ID; }

/*
    std::vector<SS> v(n);
    atcoder::lazy_segtree<SS, op, e, FF, mapping, composition, id> seg(v);
*/

void solve() {
  in(n, q);
  vset(A, n, 0);
  atcoder::lazy_segtree<SS, op, e, FF, mapping, composition, id> seg(A);
  vector<tuple<ll, ll, ll>> VT;
  rep(q) {
    in(x, y, c);
    x--;
    VT.pb({c, x, y});
  }
  sort(all(VT));
  rep(q) {
    auto [c, x, y] = VT[i];
    seg.apply(x, y, c);
  }
  rep(q) {
    auto [c, x, y] = VT[i];
    if (seg.prod(x, y) != c) {
      print(-1);
      return;
    }
  }
  rep(n) { B.pb(seg.get(i)); }
  print(B);
}
int main() {
  // cout << fixed << setprecision(15);
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cin >> codeforces;
  while (codeforces--) {
    ans = 0;
    solve();
  }
}
0