結果
問題 | No.1675 Strange Minimum Query |
ユーザー |
![]() |
提出日時 | 2024-06-11 13:26:21 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,214 bytes |
コンパイル時間 | 2,967 ms |
コンパイル使用メモリ | 217,764 KB |
実行使用メモリ | 10,964 KB |
最終ジャッジ日時 | 2024-06-11 13:26:35 |
合計ジャッジ時間 | 11,993 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 5 WA * 29 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/lazysegtree>using namespace std;using namespace atcoder;int op(int a, int b) { return min(a, b); }int e() { return 1e9; }int mapping(int f, int x) {if (f == -1) return x;return f;}int composition(int f, int g) {if (f == -1) return g;return f;}int id() { return -1; }void fast_io() {ios_base::sync_with_stdio(false);cin.tie(nullptr);}int main() {fast_io();int n, q;cin >> n >> q;vector<tuple<int, int, int>> lrb;for (int i = 0; i < q; i++) {int l, r, b;cin >> l >> r >> b;l--;lrb.push_back({l, r, b});}vector<int> idx(q);iota(idx.begin(), idx.end(), 0);sort(idx.begin(), idx.end(),[&](int i, int j) { return get<2>(lrb[i]) < get<2>(lrb[j]); });lazy_segtree<int, op, e, int, mapping, composition, id> seg(n);for (int i : idx) {auto [l, r, b] = lrb[i];seg.apply(l, r, b);}for (auto [l, r, b] : lrb) {if (seg.prod(l, r) != b) {cout << -1 << endl;return 0;}}for (int i = 0; i < n; i++) {cout << seg.get(i) << " ";}cout << endl;}