Submission #676149

# Submission time Handle Problem Language Result Execution time Memory
676149 2022-12-29T13:52:18 Z Trisanu_Das Deda (COCI17_deda) C++17
140 / 140
82 ms 3356 KB
#include <bits/stdc++.h>
using namespace std;
 
const int mxN=2e5;
int n, q, a, b, st[1<<19];
char qt;
 
void upd(int l1, int x, int i=1, int l2=0, int r2=n-1) {
	st[i]=min(x, st[i]);
	if(l2==r2)
		return;
	int m2=(l2+r2)/2;
	if(l1<=m2)
		upd(l1, x, 2*i, l2, m2);
	else
		upd(l1, x, 2*i+1, m2+1, r2);
}
 
int qry(int l1, int x, int i=1, int l2=0, int r2=n-1) {
	if(st[i]>x)
		return -2;
	if(l2==r2)
		return l2;
	int m2=(l2+r2)/2;
	int r=-2;
	if(l1<=m2)
		r=qry(l1, x, 2*i, l2, m2);
	if(r==-2)
		r=qry(l1, x, 2*i+1, m2+1, r2);
	return r;
}
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> q;
	memset(st, 0x3f, sizeof(st));
	while(q--) {
		cin >> qt >> a >> b, --b;
		if(qt=='M')
			upd(b, a);
		else
			cout << qry(b, a)+1 << "\n";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2260 KB Output is correct
2 Correct 1 ms 2260 KB Output is correct
3 Correct 3 ms 2384 KB Output is correct
4 Correct 74 ms 3348 KB Output is correct
5 Correct 76 ms 3012 KB Output is correct
6 Correct 81 ms 3176 KB Output is correct
7 Correct 82 ms 3356 KB Output is correct