結果
| 問題 |
No.1675 Strange Minimum Query
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-10 23:57:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 277 ms / 2,000 ms |
| コード長 | 1,827 bytes |
| コンパイル時間 | 3,416 ms |
| コンパイル使用メモリ | 211,204 KB |
| 最終ジャッジ日時 | 2025-01-24 12:29:05 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
#include <cstdint>
#include <string>
#include <sstream>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
typedef unsigned long long ull;
using P=pair<ll,ll>;
const ll INF=1001001001;
const int mod=1e9+7;
void solve(){
int n,Q;
cin>>n>>Q;
vector<vector<int>>t(Q,vector<int>(3));
rep(i,Q){
int l,r,b;
cin>>l>>r>>b;
l--;
t[i]={b,l,r};
}
sort(t.rbegin(),t.rend());
int pre=-1;
set<int>used,unused;
rep(i,n){unused.insert(i);}
vector<int>ans(n,1e9);
for(auto v:t){
int b=v[0],l=v[1],r=v[2];
if(b!=pre){
pre=b;
used.clear();
}
auto itr=unused.lower_bound(l);
if(itr==unused.end()||*itr>=r){
auto itr2=used.lower_bound(l);
if(itr2==used.end()||*itr2>=r){
cout<<-1<<endl;
return;
}
}
else{
while(itr!=unused.end()&&*itr<r){
ans[*itr]=b;
used.insert(*itr);
itr=unused.erase(itr);
}
}
}
rep(i,n){
if(i){cout<<" ";}
cout<<ans[i];
}
cout<<endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
return 0;
}