結果
| 問題 | 
                            No.1675 Strange Minimum Query
                             | 
                    
| コンテスト | |
| ユーザー | 
                             planes
                         | 
                    
| 提出日時 | 2021-09-11 00:04:08 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,781 bytes | 
| コンパイル時間 | 1,807 ms | 
| コンパイル使用メモリ | 188,472 KB | 
| 実行使用メモリ | 23,400 KB | 
| 最終ジャッジ日時 | 2024-06-12 07:16:08 | 
| 合計ジャッジ時間 | 10,117 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 WA * 2 | 
| other | AC * 5 WA * 29 | 
ソースコード
#include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
ll INF=2e18;
const ll MAX_N=1<<17;
ll n;
vector<ll> dat;
void init(ll n_) {
    n=1;
    while (n<n_) n*=2;
dat=vector<ll> (2*n-1,INF);
   
}
    void update(ll k, ll a) {
        k+=n-1;
        dat[k]=a;
        while(k>0) {
            k=(k-1)/2;
            dat[k]=min(dat[k*2+1],dat[2*k+2]);
        }
    }
    ll query (ll a, ll b, ll k,ll l, ll r) {
        if(r<=a||b<=l) return INF;
        if(a<=l&&r<=b) return dat[k];
        else {
            ll vl=query(a,b,k*2+1,l,(l+r)/2);
            ll vr=query(a,b,k*2+2,(l+r)/2,r);
            return min(vl,vr);
        }
    }
int main() {
  ll N,Q;cin>>N>>Q;
  vector<tuple<ll,ll,ll>> vec(Q);
  for(ll i=0;i<Q;i++) {
    cin>>get<0>(vec[i])>>get<1>(vec[i])>>get<2>(vec[i]);
    get<0>(vec[i])--;get<1>(vec[i])--;
  }
  sort(all(vec));
  vec.push_back(make_tuple(N,N+1,0));
  priority_queue<pair<ll,ll>> S;
vector<ll> A(N);
ll R=N-1;
ll t=1;
ll ind=-1;
ll i=0;
while(i<N) {
  if(get<0>(vec[ind+1])>i&&i<=R) {
    A[i]=t;
    i++;
  }
  else if(get<0>(vec[ind+1])==i) {
    if(get<2>(vec[ind+1])>=t) {
      S.push(make_pair(t,R));
      t=get<2>(vec[ind+1]);
      R=get<1>(vec[ind+1]);
    }
    else {
      S.push(make_pair(get<2>(vec[ind+1]),get<1>(vec[ind+1])));
    }
    ind++;
  }
  else {
    auto x=S.top();S.pop();
    t=x.first;R=x.second;
  }
}
init(N);
for(ll i=0;i<N;i++) {
  update(i,A[i]);
}
for(ll i=0;i<Q;i++) {
  ll k=query(get<0>(vec[i]),get<1>(vec[i])+1,0,0,n);
  if(k!=get<2>(vec[i])) {
    cout<<-1<<endl;
    return 0;
  }
}
for(auto x:A) {
  cout<<x<<" ";
}
cout<<endl;
}
  
    
      
    
            
            
            
        
            
planes