結果

問題 No.1675 Strange Minimum Query
ユーザー inksamuraiinksamurai
提出日時 2021-09-10 22:48:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 215 ms / 2,000 ms
コード長 1,503 bytes
コンパイル時間 3,788 ms
コンパイル使用メモリ 242,812 KB
実行使用メモリ 19,560 KB
最終ジャッジ日時 2024-06-12 02:26:14
合計ジャッジ時間 12,103 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 66 ms
7,148 KB
testcase_04 AC 80 ms
11,756 KB
testcase_05 AC 50 ms
11,152 KB
testcase_06 AC 76 ms
7,660 KB
testcase_07 AC 96 ms
10,728 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 147 ms
14,824 KB
testcase_11 AC 69 ms
13,184 KB
testcase_12 AC 164 ms
16,108 KB
testcase_13 AC 156 ms
19,304 KB
testcase_14 AC 170 ms
19,176 KB
testcase_15 AC 157 ms
19,304 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 37 ms
7,168 KB
testcase_18 AC 46 ms
7,656 KB
testcase_19 AC 102 ms
16,232 KB
testcase_20 AC 131 ms
14,952 KB
testcase_21 AC 139 ms
17,516 KB
testcase_22 AC 169 ms
18,404 KB
testcase_23 AC 97 ms
9,192 KB
testcase_24 AC 107 ms
12,516 KB
testcase_25 AC 68 ms
8,164 KB
testcase_26 AC 55 ms
9,580 KB
testcase_27 AC 139 ms
17,896 KB
testcase_28 AC 85 ms
14,060 KB
testcase_29 AC 88 ms
15,616 KB
testcase_30 AC 54 ms
9,856 KB
testcase_31 AC 125 ms
10,724 KB
testcase_32 AC 199 ms
19,304 KB
testcase_33 AC 198 ms
19,308 KB
testcase_34 AC 192 ms
19,356 KB
testcase_35 AC 203 ms
19,560 KB
testcase_36 AC 215 ms
19,300 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:43:25: warning: narrowing conversion of 'val' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
   43 |                 qry.pb({val,{l,r}});
      |                         ^~~

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
//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<int,pii>;
using vi=vec(int);
const int mxn=12000;

int op(int l,int r){
	return min(l,r);
}

int e(){
	return inf;
}

int main(){
_3E0svGb;
	int n,m;
	cin>>n>>m;
	vec(tpii) qry;
	rep(i,m){
		ll l,r,val;
		cin>>l>>r>>val;
		l--,r--;
		qry.pb({val,{l,r}});
	}
	sort(all(qry));
	reverse(all(qry));
	vec(ll) a(n,-1);
	set<int> st;
	rep(i,n) st.insert(i);
	atcoder::segtree<int,op,e> seg(n);
	rep(i,n) seg.set(i,inf);
	rep(i,sz(qry)){
		int l=qry[i].se.fi,r=qry[i].se.se;
		int val=qry[i].fi;
		auto it=st.lower_bound(l);
		if((it==st.end() or *it>r) and seg.prod(l,r+1)>val){
			printf("-1\n");
			exit(0);
		}
		while(true){
			auto ti=st.lower_bound(l);
			if(*ti>r or ti==st.end()) break;
			a[*ti]=val;
			seg.set(*ti,val);
			st.erase(ti);
		}
	}
	rep(i,n){
		cout<<(a[i]==-1?inf:a[i]);
		if(i<n-1) cout<<" ";
	}
	cout<<"\n";
//	
	return 0;
}
0