結果
問題 |
No.1675 Strange Minimum Query
|
ユーザー |
![]() |
提出日時 | 2021-08-06 13:22:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 540 ms / 2,000 ms |
コード長 | 923 bytes |
コンパイル時間 | 4,840 ms |
コンパイル使用メモリ | 257,844 KB |
最終ジャッジ日時 | 2025-01-23 14:19:30 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < int(n); i++) #define all(v) v.begin(), v.end() using S = int; using F = int; S op(S a, S b) { return min(a, b); } S e() { return int(1e9); } S mapping(F x, S a) { return x == -1 ? a : x; } F composition(F f, F g) { return f == -1 ? g : f; } F id() { return -1; } int main() { int n, q; cin >> n >> q; vector<array<int, 3>> query(q); rep(i, q) { int l, r, b; cin >> l >> r >> b; l--; query[i] = {b, l, r}; } sort(all(query)); atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(n); for (auto [b, l, r] : query) seg.apply(l, r, b); for (auto [b, l, r] : query) { if (seg.prod(l, r) != b) { cout << -1 << "\n"; return 0; } } rep(i, n) cout << seg.get(i) << (i + 1 == n ? "\n" : " "); }