結果

問題 No.1675 Strange Minimum Query
ユーザー kwm_tkwm_t
提出日時 2021-09-10 22:08:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 254 ms / 2,000 ms
コード長 1,907 bytes
コンパイル時間 4,060 ms
コンパイル使用メモリ 234,324 KB
実行使用メモリ 9,508 KB
最終ジャッジ日時 2023-09-02 17:56:54
合計ジャッジ時間 13,408 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 120 ms
5,492 KB
testcase_04 AC 107 ms
6,460 KB
testcase_05 AC 10 ms
5,224 KB
testcase_06 AC 142 ms
6,020 KB
testcase_07 AC 152 ms
7,248 KB
testcase_08 AC 2 ms
4,368 KB
testcase_09 AC 3 ms
4,368 KB
testcase_10 AC 87 ms
7,588 KB
testcase_11 AC 28 ms
6,796 KB
testcase_12 AC 95 ms
7,804 KB
testcase_13 AC 151 ms
9,432 KB
testcase_14 AC 190 ms
9,292 KB
testcase_15 AC 174 ms
9,232 KB
testcase_16 AC 2 ms
4,372 KB
testcase_17 AC 38 ms
4,440 KB
testcase_18 AC 52 ms
4,624 KB
testcase_19 AC 74 ms
7,248 KB
testcase_20 AC 164 ms
8,376 KB
testcase_21 AC 144 ms
8,048 KB
testcase_22 AC 191 ms
8,580 KB
testcase_23 AC 148 ms
5,732 KB
testcase_24 AC 133 ms
6,204 KB
testcase_25 AC 97 ms
5,272 KB
testcase_26 AC 49 ms
5,420 KB
testcase_27 AC 129 ms
8,180 KB
testcase_28 AC 70 ms
7,320 KB
testcase_29 AC 50 ms
7,012 KB
testcase_30 AC 48 ms
5,444 KB
testcase_31 AC 196 ms
6,992 KB
testcase_32 AC 254 ms
9,436 KB
testcase_33 AC 252 ms
9,508 KB
testcase_34 AC 253 ms
9,372 KB
testcase_35 AC 237 ms
9,372 KB
testcase_36 AC 237 ms
9,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#include "atcoder/all"
using namespace std;
using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
const int INF = 1e9;
//const long long LINF = 1e18;
//const bool debug = false;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
using S = int;
using F = int;
const F ID = INF + 1;


S op(S a, S b) { return std::min(a, b); }
S e() { return INF; }
S mapping(F f, S x) { return (f == ID ? x : f); }
F composition(F f, F g) { return (f == ID ? g : f); }
F id() { return ID; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, q; cin >> n >> q;
	vector<pair<int, P>>v(q);
	rep(i, q) {
		int l, r, b; cin >> l >> r >> b;
		l--; r--;
		v[i] = { b,{l,r} };
	}
	sort(all(v));
	vector<int>vs(n, 1);
	lazy_segtree<S, op, e, F, mapping, composition, id> seg(vs);
	rep(i, q) {
		int x = v[i].first;
		int l = v[i].second.first;
		int r = v[i].second.second;
		seg.apply(l, r + 1, x);
	}
	/*rep(i, n) {
		cout << seg.get(i);
		if ((n - 1) != i)cout << " ";
		else  cout << endl;
	}*/
	rep(i, q) {
		int x = v[i].first;
		int l = v[i].second.first;
		int r = v[i].second.second;
		int y = seg.prod(l, r + 1);
		if (x != y) {
			cout << -1 << endl;
			return 0;
		}
	}
	rep(i, n) {
		cout << seg.get(i);
		if ((n - 1) != i)cout << " ";
		else  cout << endl;
	}
	return 0;
}
0