結果
問題 | No.1675 Strange Minimum Query |
ユーザー | miscalc |
提出日時 | 2021-09-10 23:36:29 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 376 ms / 2,000 ms |
コード長 | 1,809 bytes |
コンパイル時間 | 2,566 ms |
コンパイル使用メモリ | 216,504 KB |
実行使用メモリ | 15,748 KB |
最終ジャッジ日時 | 2023-09-02 22:53:01 |
合計ジャッジ時間 | 14,495 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,368 KB |
testcase_01 | AC | 2 ms
4,368 KB |
testcase_02 | AC | 1 ms
4,372 KB |
testcase_03 | AC | 226 ms
7,976 KB |
testcase_04 | AC | 203 ms
10,232 KB |
testcase_05 | AC | 24 ms
7,164 KB |
testcase_06 | AC | 263 ms
8,692 KB |
testcase_07 | AC | 287 ms
11,404 KB |
testcase_08 | AC | 1 ms
4,368 KB |
testcase_09 | AC | 3 ms
4,368 KB |
testcase_10 | AC | 142 ms
11,892 KB |
testcase_11 | AC | 47 ms
10,424 KB |
testcase_12 | AC | 158 ms
12,456 KB |
testcase_13 | AC | 277 ms
15,544 KB |
testcase_14 | AC | 332 ms
15,468 KB |
testcase_15 | AC | 296 ms
15,316 KB |
testcase_16 | AC | 2 ms
4,368 KB |
testcase_17 | AC | 55 ms
5,644 KB |
testcase_18 | AC | 80 ms
6,072 KB |
testcase_19 | AC | 107 ms
11,380 KB |
testcase_20 | AC | 244 ms
13,332 KB |
testcase_21 | AC | 214 ms
12,912 KB |
testcase_22 | AC | 284 ms
13,952 KB |
testcase_23 | AC | 227 ms
8,280 KB |
testcase_24 | AC | 202 ms
9,644 KB |
testcase_25 | AC | 149 ms
7,060 KB |
testcase_26 | AC | 72 ms
7,420 KB |
testcase_27 | AC | 190 ms
12,952 KB |
testcase_28 | AC | 100 ms
11,400 KB |
testcase_29 | AC | 70 ms
10,880 KB |
testcase_30 | AC | 70 ms
7,592 KB |
testcase_31 | AC | 298 ms
10,860 KB |
testcase_32 | AC | 376 ms
15,268 KB |
testcase_33 | AC | 372 ms
15,748 KB |
testcase_34 | AC | 375 ms
15,392 KB |
testcase_35 | AC | 366 ms
15,336 KB |
testcase_36 | AC | 372 ms
15,360 KB |
ソースコード
#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/lazysegtree> ll op(ll a, ll b) { return min(a, b); } ll e() { return INF; } ll mapping(ll f, ll x) { return (f == INF ? x : f); } ll composition(ll f, ll g) { return (f == INF ? g : f); } ll id() { 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()); lazy_segtree<ll, op, e, ll, mapping, composition, id> seg(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); seg.apply(l, r, b); } for (ll i = 0; i < N; i++) { if (seg.get(i) == INF) seg.set(i, 1e9); } 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' : ' '); } }