結果

問題 No.1675 Strange Minimum Query
ユーザー inksamuraiinksamurai
提出日時 2021-09-10 22:06:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,494 bytes
コンパイル時間 2,038 ms
コンパイル使用メモリ 181,004 KB
実行使用メモリ 20,572 KB
最終ジャッジ日時 2023-09-02 17:50:19
合計ジャッジ時間 7,198 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 1 ms
4,368 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 63 ms
7,180 KB
testcase_04 AC 60 ms
10,936 KB
testcase_05 AC 10 ms
9,556 KB
testcase_06 AC 74 ms
7,900 KB
testcase_07 AC 86 ms
11,172 KB
testcase_08 AC 1 ms
4,368 KB
testcase_09 AC 2 ms
4,372 KB
testcase_10 AC 125 ms
14,936 KB
testcase_11 AC 46 ms
12,652 KB
testcase_12 AC 137 ms
15,732 KB
testcase_13 AC 174 ms
16,100 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1 ms
4,368 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//eolibraries
#define lnf 3999999999999999999
#define inf 999999999+1
#define fi first
#define se second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end());
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define vec(...) vector<__VA_ARGS__>
#define _3E0svGb ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//eodefine
using namespace std;
typedef long long ll;
typedef long double ld;
using pii=pair<int,int>;
using tpii=pair<pii,int>;
using vi=vec(int);
const int mxn=12000;

struct lazy_segtree{
	int n;
	vi seg,lazy,flag;
	lazy_segtree(int m){
		init(m);
	}
	void init(int m){
		n=1;
		while(n<m) n*=2;
		seg.clear();
		lazy.clear();
		flag.clear();
		seg.resize(2*n,inf);
		lazy.resize(2*n,0);
		flag.resize(2*n,false);
	}
	void push(int l,int r,int node){
		if(flag[node]){
			seg[node]=lazy[node];
			if(node<n){
				// lazy merge
				lazy[node*2]=lazy[node];
				lazy[node*2+1]=lazy[node];
				flag[node*2]=flag[node*2+1]=true;
			}
			flag[node]=false;
			lazy[node]=0;
		}

	}
	void set(int node,int l,int r,int x,int _l,int _r){
		push(l,r,node);
		if(l>=_r or r<=_l) return;
		if(l>=_l and r<=_r){
			lazy[node]=x;
			flag[node]=true;
			push(l,r,node);
			return;
		}
		int m=(l+r)>>1;
		set(node*2,l,m,x,_l,_r);
		set(node*2+1,m,r,x,_l,_r);
		// prod seg_node
		seg[node]=min(seg[node*2],seg[node*2+1]); 
	}
	int prod(int node,int l,int r,int _l,int _r){
		push(l,r,node);
		// _e
		if(l>=_r or r<=_l) return inf; 
		if(l>=_l and r<=_r) return seg[node];
		int m=(l+r)>>1;
		int vl=prod(node*2,l,m,_l,_r);
		int vr=prod(node*2+1,m,r,_l,_r);
		return min(vl,vr);
	}
	void set(int l,int r,int x){
		// [l,r)
		set(1,0,n,x,l,r);
	}
	int prod(int l,int r){
		// [l,r)
		return prod(1,0,n,l,r);
	}
};

int main(){
_3E0svGb;
	int n,m;
	cin>>n>>m;
	lazy_segtree seg(n);
	vec(vec(pii)) qry(n);
	rep(i,m){
		ll l,r,val;
		cin>>l>>r>>val;
		l--,r--;
		qry[r].pb({l,val});	
	}
	rep(i,n){
		for(auto p : qry[i]){
			int l=p.fi,val=p.se;
			if(seg.prod(l,i+1)!=inf and seg.prod(l,i+1)>val){
				printf("-1\n");
				exit(0);
			}
			seg.set(l,i+1,val);
		}
	}
	rep(i,n){
		for(auto p : qry[i]){
			int l=p.fi,val=p.se;
			if(seg.prod(l,i+1)!=val){
				printf("-1\n");
				exit(0);
			}
		}
	}
	rep(i,n){
		cout<<seg.prod(i,i+1);
		if(i<n-1) cout<<" ";
	}
	cout<<"\n";
//	
	return 0;
}
0