結果

問題 No.1675 Strange Minimum Query
ユーザー aut_jul_dur
提出日時 2021-09-10 23:52:49
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 393 ms / 2,000 ms
コード長 1,544 bytes
コンパイル時間 4,216 ms
コンパイル使用メモリ 240,092 KB
実行使用メモリ 15,772 KB
最終ジャッジ日時 2024-06-12 06:29:59
合計ジャッジ時間 15,939 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const long long MOD = 998244353;
//const long long INF = 9*1e18;
using ll = long long;
using mint = modint998244353;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
long double PI = 3.14159265358979;
using S = long long;
using F = long long;

const S INF = 1e10;
const F ID = 1e10;

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; }

int main(){
  ll N,Q;
  cin>>N>>Q;
  vector<ll> v;
  v.assign(N,INF);
  lazy_segtree<S,op,e,F,mapping,composition,id> seg(v);
  vector<tuple<ll,ll,ll>> A(Q);
  rep(i,Q){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;
    A[i] = {c,a,b};
  }
  sort(all(A));
  rep(i,Q){
    seg.apply(get<1>(A[i]),get<2>(A[i]),get<0>(A[i]));
  }
  bool d = 0;
  rep(i,Q){
    if(seg.prod(get<1>(A[i]),get<2>(A[i])) != get<0>(A[i])){
      d = 1;
    }
  }
  if(d){
    cout << -1 << endl;
  }
  else{
    rep(i,N-1){
      if(seg.get(i) == INF){
        cout << 1000000000 << " ";
      }
      else{
        cout << seg.get(i) << " ";
      }
    }
    if(seg.get(N-1) == INF){
      cout << 1000000000 << endl;
    }
    else{
      cout <<seg.get(N-1) << endl;
    }
  }
  return 0;
}
0