結果

問題 No.1675 Strange Minimum Query
ユーザー inksamuraiinksamurai
提出日時 2021-09-10 22:48:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 234 ms / 2,000 ms
コード長 1,503 bytes
コンパイル時間 4,255 ms
コンパイル使用メモリ 238,776 KB
実行使用メモリ 19,548 KB
最終ジャッジ日時 2023-09-02 20:04:04
合計ジャッジ時間 13,462 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 77 ms
7,344 KB
testcase_04 AC 91 ms
11,092 KB
testcase_05 AC 55 ms
10,980 KB
testcase_06 AC 88 ms
7,768 KB
testcase_07 AC 106 ms
10,832 KB
testcase_08 AC 2 ms
4,368 KB
testcase_09 AC 3 ms
4,368 KB
testcase_10 AC 162 ms
14,828 KB
testcase_11 AC 76 ms
13,184 KB
testcase_12 AC 188 ms
15,888 KB
testcase_13 AC 176 ms
19,276 KB
testcase_14 AC 190 ms
19,288 KB
testcase_15 AC 176 ms
19,288 KB
testcase_16 AC 2 ms
4,368 KB
testcase_17 AC 40 ms
6,864 KB
testcase_18 AC 50 ms
7,608 KB
testcase_19 AC 114 ms
16,040 KB
testcase_20 AC 144 ms
15,016 KB
testcase_21 AC 154 ms
17,196 KB
testcase_22 AC 185 ms
19,176 KB
testcase_23 AC 107 ms
9,200 KB
testcase_24 AC 119 ms
12,268 KB
testcase_25 AC 76 ms
8,144 KB
testcase_26 AC 59 ms
9,500 KB
testcase_27 AC 151 ms
17,476 KB
testcase_28 AC 94 ms
13,840 KB
testcase_29 AC 98 ms
15,312 KB
testcase_30 AC 61 ms
9,840 KB
testcase_31 AC 133 ms
10,780 KB
testcase_32 AC 218 ms
19,108 KB
testcase_33 AC 216 ms
19,432 KB
testcase_34 AC 216 ms
19,548 KB
testcase_35 AC 228 ms
19,200 KB
testcase_36 AC 234 ms
19,088 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:43:25: 警告: 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