結果

問題 No.1675 Strange Minimum Query
ユーザー aut_jul_duraut_jul_dur
提出日時 2021-09-10 23:52:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 384 ms / 2,000 ms
コード長 1,544 bytes
コンパイル時間 4,235 ms
コンパイル使用メモリ 237,580 KB
実行使用メモリ 15,604 KB
最終ジャッジ日時 2023-09-03 00:45:04
合計ジャッジ時間 16,267 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 264 ms
7,988 KB
testcase_04 AC 237 ms
10,180 KB
testcase_05 AC 21 ms
7,268 KB
testcase_06 AC 312 ms
8,540 KB
testcase_07 AC 336 ms
11,496 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 146 ms
12,024 KB
testcase_11 AC 41 ms
10,436 KB
testcase_12 AC 160 ms
12,212 KB
testcase_13 AC 281 ms
15,336 KB
testcase_14 AC 329 ms
15,604 KB
testcase_15 AC 296 ms
15,464 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 58 ms
5,752 KB
testcase_18 AC 81 ms
6,016 KB
testcase_19 AC 112 ms
11,444 KB
testcase_20 AC 248 ms
13,248 KB
testcase_21 AC 220 ms
12,964 KB
testcase_22 AC 286 ms
14,084 KB
testcase_23 AC 229 ms
8,312 KB
testcase_24 AC 204 ms
9,648 KB
testcase_25 AC 150 ms
6,972 KB
testcase_26 AC 75 ms
7,668 KB
testcase_27 AC 195 ms
12,744 KB
testcase_28 AC 105 ms
11,296 KB
testcase_29 AC 76 ms
11,164 KB
testcase_30 AC 73 ms
7,596 KB
testcase_31 AC 301 ms
10,964 KB
testcase_32 AC 383 ms
15,464 KB
testcase_33 AC 378 ms
15,380 KB
testcase_34 AC 384 ms
15,268 KB
testcase_35 AC 372 ms
15,468 KB
testcase_36 AC 374 ms
15,332 KB
権限があれば一括ダウンロードができます

ソースコード

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