結果

問題 No.1675 Strange Minimum Query
ユーザー 沙耶花沙耶花
提出日時 2021-09-10 21:40:36
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 217 ms / 2,000 ms
コード長 1,232 bytes
コンパイル時間 4,560 ms
コンパイル使用メモリ 269,068 KB
実行使用メモリ 15,020 KB
最終ジャッジ日時 2023-09-02 16:26:50
合計ジャッジ時間 13,312 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 104 ms
6,916 KB
testcase_04 AC 106 ms
9,444 KB
testcase_05 AC 40 ms
7,596 KB
testcase_06 AC 123 ms
7,524 KB
testcase_07 AC 142 ms
10,084 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 85 ms
12,132 KB
testcase_11 AC 51 ms
10,992 KB
testcase_12 AC 95 ms
12,732 KB
testcase_13 AC 143 ms
14,688 KB
testcase_14 AC 179 ms
14,764 KB
testcase_15 AC 163 ms
15,020 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 36 ms
5,760 KB
testcase_18 AC 49 ms
6,028 KB
testcase_19 AC 95 ms
12,056 KB
testcase_20 AC 143 ms
12,924 KB
testcase_21 AC 140 ms
13,200 KB
testcase_22 AC 172 ms
13,864 KB
testcase_23 AC 108 ms
7,776 KB
testcase_24 AC 118 ms
9,208 KB
testcase_25 AC 76 ms
6,920 KB
testcase_26 AC 52 ms
7,568 KB
testcase_27 AC 131 ms
12,852 KB
testcase_28 AC 80 ms
11,500 KB
testcase_29 AC 75 ms
11,620 KB
testcase_30 AC 52 ms
7,984 KB
testcase_31 AC 144 ms
10,080 KB
testcase_32 AC 215 ms
14,628 KB
testcase_33 AC 217 ms
14,764 KB
testcase_34 AC 217 ms
14,968 KB
testcase_35 AC 196 ms
14,664 KB
testcase_36 AC 193 ms
14,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001

using P = pair<int,int>;

P op(P a,P b){
	return max(a,b);
}

P e(){
	return make_pair(-Inf,-1);
}

int op2(int a,int b){
	return min(a,b);
}
int e2(){
	return Inf;
}

int main(){
	
	int n,q;
	cin>>n>>q;
	vector<P> temp(n);
	rep(i,n){
		temp[i] = make_pair(Inf,i);
	}
	segtree<P,op,e> seg(temp);
	
	vector<int> l(q),r(q),b(q);
	rep(i,q){
		scanf("%d %d %d",&l[i],&r[i],&b[i]);
		l[i]--;
	}
	vector<int> t(q);
	rep(i,q)t[i] = i;
	
	sort(t.rbegin(),t.rend(),[&](int x,int y){
		return b[x]<b[y];
	});
	
	rep(i,q){
		int ind = t[i];
		while(true){
			P ret = seg.prod(l[ind],r[ind]);
			if(ret.first!=Inf)break;
			seg.set(ret.second,make_pair(b[ind],ret.second));
		}
	}
	
	while(true){
		P ret = seg.prod(0,n);
		if(ret.first!=Inf)break;
		seg.set(ret.second,make_pair(1000000000,0));
		
	}
	segtree<int,op2,e2> seg2(n);
	rep(i,n){
		seg2.set(i,seg.get(i).first);
	}
	rep(i,q){
		if(seg2.prod(l[i],r[i])!=b[i]){
			cout<<-1<<endl;
			return 0;
		}
		
	}
	
	rep(i,n){
		if(i!=0)cout<<' ';
		cout<<seg.get(i).first;
	}
	cout<<endl;
	
		
	
	return 0;
}
0