Submission #674928

# Submission time Handle Problem Language Result Execution time Memory
674928 2022-12-26T15:47:00 Z QwertyPi RMQ (NOI17_rmq) C++14
30 / 100
164 ms 4168 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e6 + 11;
struct SegTree{
	int t[MAXN << 2];
	void upd(int ql, int qr, int val, int v, int l, int r){
		if(qr < l || r < ql) return;
		if(ql <= l && r <= qr){
			t[v] = max(t[v], val);
			return;
		}
		t[v * 2 + 1] = max(t[v], t[v * 2 + 1]);
		t[v * 2 + 2] = max(t[v], t[v * 2 + 2]);
		int m = (l + r) / 2;
		upd(ql, qr, val, v * 2 + 1, l, m);
		upd(ql, qr, val, v * 2 + 2, m + 1, r);
		t[v] = min(t[v * 2 + 1], t[v * 2 + 2]);
	}
	
	int qry(int ql, int qr, int v, int l, int r){
		if(qr < l || r < ql) return (1 << 30);
		if(ql <= l && r <= qr) return t[v];
		t[v * 2 + 1] = max(t[v], t[v * 2 + 1]);
		t[v * 2 + 2] = max(t[v], t[v * 2 + 2]);
		int m = (l + r) / 2;
		return min(qry(ql, qr, v * 2 + 1, l, m), qry(ql, qr, v * 2 + 2, m + 1, r));
	}
} segTree;

struct con{
	int l, r, m;
};

int main(){
	int n, q; cin >> n >> q;
	vector<con> cons;
	for(int i = 0; i < q; i++){
		int l, r, m; cin >> l >> r >> m;
		cons.push_back({l, r, m});
		segTree.upd(l, r, m, 0, 0, n - 1);
	}
	
	auto lose = [&n](){
		for(int i = 0; i < n; i++){
			cout << -1 << ' ';
		}
		cout << endl;
		exit(0);
	};
	
	for(int i = 0; i < q; i++){
		int q = segTree.qry(cons[i].l, cons[i].r, 0, 0, n - 1);
		if(q > cons[i].m) lose();
	}
	
	for(int i = 0; i < n; i++){
		cout << segTree.qry(i, i, 0, 0, n - 1) << ' ';
	}
	cout << endl;
}
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 212 KB Output is partially correct
2 Partially correct 0 ms 212 KB Output is partially correct
3 Partially correct 1 ms 308 KB Output is partially correct
4 Partially correct 1 ms 212 KB Output is partially correct
5 Partially correct 1 ms 212 KB Output is partially correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Partially correct 0 ms 212 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 212 KB Output is partially correct
2 Partially correct 0 ms 212 KB Output is partially correct
3 Partially correct 1 ms 308 KB Output is partially correct
4 Partially correct 1 ms 212 KB Output is partially correct
5 Partially correct 1 ms 212 KB Output is partially correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Partially correct 0 ms 212 KB Output is partially correct
12 Partially correct 2 ms 340 KB Output is partially correct
13 Partially correct 1 ms 340 KB Output is partially correct
14 Partially correct 1 ms 312 KB Output is partially correct
15 Partially correct 1 ms 340 KB Output is partially correct
16 Partially correct 2 ms 340 KB Output is partially correct
17 Partially correct 2 ms 312 KB Output is partially correct
18 Partially correct 1 ms 340 KB Output is partially correct
19 Partially correct 1 ms 212 KB Output is partially correct
20 Partially correct 1 ms 212 KB Output is partially correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Partially correct 0 ms 212 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 212 KB Output is partially correct
2 Partially correct 0 ms 212 KB Output is partially correct
3 Partially correct 1 ms 308 KB Output is partially correct
4 Partially correct 1 ms 212 KB Output is partially correct
5 Partially correct 1 ms 212 KB Output is partially correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Partially correct 0 ms 212 KB Output is partially correct
12 Partially correct 2 ms 340 KB Output is partially correct
13 Partially correct 1 ms 340 KB Output is partially correct
14 Partially correct 1 ms 312 KB Output is partially correct
15 Partially correct 1 ms 340 KB Output is partially correct
16 Partially correct 2 ms 340 KB Output is partially correct
17 Partially correct 2 ms 312 KB Output is partially correct
18 Partially correct 1 ms 340 KB Output is partially correct
19 Partially correct 1 ms 212 KB Output is partially correct
20 Partially correct 1 ms 212 KB Output is partially correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Partially correct 0 ms 212 KB Output is partially correct
27 Partially correct 164 ms 4160 KB Output is partially correct
28 Partially correct 129 ms 4056 KB Output is partially correct
29 Partially correct 102 ms 3368 KB Output is partially correct
30 Partially correct 144 ms 4088 KB Output is partially correct
31 Partially correct 112 ms 3460 KB Output is partially correct
32 Partially correct 132 ms 3404 KB Output is partially correct
33 Partially correct 16 ms 1492 KB Output is partially correct
34 Partially correct 12 ms 956 KB Output is partially correct
35 Partially correct 30 ms 1816 KB Output is partially correct
36 Correct 67 ms 3168 KB Output is correct
37 Correct 98 ms 4168 KB Output is correct
38 Correct 5 ms 596 KB Output is correct
39 Correct 85 ms 3976 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Partially correct 1 ms 212 KB Output is partially correct