結果
| 問題 |
No.1675 Strange Minimum Query
|
| コンテスト | |
| ユーザー |
hiro71687k
|
| 提出日時 | 2023-04-07 15:46:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 407 ms / 2,000 ms |
| コード長 | 1,527 bytes |
| コンパイル時間 | 4,613 ms |
| コンパイル使用メモリ | 260,832 KB |
| 最終ジャッジ日時 | 2025-02-11 23:44:43 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
using S = long long;
using F = long long;
ll inf=1000000000;
const S INF = inf;
const F ID = inf+1;
S op(S a, S b){ return std::min(a, b); }
S e(){ return INF; }
S mapping(F f, S x){ return (f == ID ? x : f); }
F composition(F f, F g){ return (f == ID ? g : f); }
F id(){ return ID; }
ld pie=3.141592653589793;
ll mod=1000000007;
int main(){
ll n,q;
cin >> n >> q;
vector<ll>l(q),r(q),b(q);
vector<pair<ll,pair<ll,ll>>>p(q);
for (ll i = 0; i < q; i++)
{
cin >> l[i] >> r[i] >> b[i];
l[i]--;
p[i]={b[i],{l[i],r[i]}};
}
sort(p.begin(),p.end());
vector<ll>v(n,inf);
atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);
for (ll i = 0; i < p.size(); i++)
{
seg.apply(p[i].second.first,p[i].second.second,p[i].first);
}
bool ok=true;
for (ll i = 0; i < p.size(); i++)
{
ll x=seg.prod(p[i].second.first,p[i].second.second);
if (x!=p[i].first)
{
ok=false;
break;
}
}
if (ok)
{
vector<ll>a(n);
for (ll i = 0; i < n; i++)
{
a[i]=seg.get(i);
}
for (ll i = 0; i < n; i++)
{
cout << a[i];
if (i<n-1)
{
cout << ' ';
}
}
cout << endl;
}else{
cout << -1 << endl;
}
}
hiro71687k