結果

問題 No.1675 Strange Minimum Query
ユーザー miscalcmiscalc
提出日時 2021-09-10 21:54:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,830 bytes
コンパイル時間 5,309 ms
コンパイル使用メモリ 214,324 KB
実行使用メモリ 19,564 KB
最終ジャッジ日時 2023-09-02 17:05:07
合計ジャッジ時間 14,118 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 233 ms
8,780 KB
testcase_04 AC 219 ms
12,360 KB
testcase_05 AC 35 ms
9,604 KB
testcase_06 AC 272 ms
9,432 KB
testcase_07 AC 301 ms
13,860 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 270 ms
19,520 KB
testcase_14 AC 321 ms
19,432 KB
testcase_15 AC 292 ms
19,564 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 53 ms
6,628 KB
testcase_18 AC 77 ms
6,972 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 278 ms
18,160 KB
testcase_23 AC 218 ms
9,324 KB
testcase_24 AC 196 ms
11,764 KB
testcase_25 AC 144 ms
8,076 KB
testcase_26 WA -
testcase_27 AC 191 ms
16,832 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 283 ms
13,068 KB
testcase_32 AC 369 ms
19,492 KB
testcase_33 AC 364 ms
19,496 KB
testcase_34 AC 369 ms
19,392 KB
testcase_35 AC 348 ms
19,528 KB
testcase_36 AC 348 ms
19,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
//using mint = modint1000000007;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using tlll = tuple<ll, ll, ll>;
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll safemod(ll A, ll M) {return (A % M + M) % M;}
ll divfloor(ll A, ll B) {if (B < 0) {return divfloor(-A, -B);} return (A - safemod(A, B)) / B;}
ll divceil(ll A, ll B) {if (B < 0) {return divceil(-A, -B);} return divfloor(A + B - 1, B);}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

#include <atcoder/segtree>
#include <atcoder/lazysegtree>

ll mymin(ll a, ll b)
{
  return min(a, b);
}

ll inf()
{
  return INF;
}

ll mymax(ll a, ll b)
{
  return max(a, b);
}

ll minusinf()
{
  return -INF;
}

int main()
{
  ll N, Q;
  cin >> N >> Q;
  vector<tlll> BLR(Q);
  for (ll q = 0; q < Q; q++)
  {
    ll l, r, b;
    cin >> l >> r >> b;
    l--;
    BLR.at(q) = make_tuple(b, l, r);
  }

  sort(BLR.begin(), BLR.end(), greater<tlll>());

  lazy_segtree<ll, mymax, minusinf, ll, mymax, mymax, minusinf> lseg(N);
  for (ll q = 0; q < Q; q++)
  {
    auto blr = BLR.at(q);
    ll b = get<0>(blr), l = get<1>(blr), r = get<2>(blr);

    lseg.apply(l, r, b);
  }

  segtree<ll, mymin, inf> seg(N);
  for (ll i = 0; i < N; i++)
  {
    seg.set(i, min((ll)1e9, lseg.get(i)));
  }

  for (ll q = 0; q < Q; q++)
  {
    auto blr = BLR.at(q);
    ll b = get<0>(blr), l = get<1>(blr), r = get<2>(blr);

    if (seg.prod(l, r) != b)
      FINALANS(-1);
  }

  for (ll i = 0; i < N; i++)
  {
    cout << seg.get(i) << (i == N - 1 ? '\n' : ' ');
  }
}
0