Submission #1271364

#TimeUsernameProblemLanguageResultExecution timeMemory
1271364SmuggingSpunDeda (COCI17_deda)C++20
140 / 140
74 ms4424 KiB
#include<bits/stdc++.h>
#define taskname "E"
using namespace std;
template<class T>void minimize(T& a, T b){
	if(a > b){
		a = b;
	}
}
const int lim = 2e5 + 5;
int n, q, st[lim << 2];
void update(int id, int l, int r, int p, int x){
	minimize(st[id], x);
	if(l == r){
		return;
	}
	int m = (l + r) >> 1;
	if(m < p){
		update(id << 1 | 1, m + 1, r, p, x);
	}
	else{
		update(id << 1, l, m, p, x);
	}
}
int get(int id, int l, int r, int B, int Y){
	if(r < B){
		return -1;
	}
	if(l >= B && st[id] > Y){
		return -1;
	}
	if(l == r){
		return l;
	}
	int m = (l + r) >> 1, left = get(id << 1, l, m, B, Y);
	return left != -1 ? left : get(id << 1 | 1, m + 1, r, B, Y);
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	if(fopen(taskname".inp", "r")){
		freopen(taskname".inp", "r", stdin);
	}
	cin >> n >> q;
	memset(st, 0x3f, sizeof(st));
	for(int _ = 0; _ < q; _++){
		char c;
		int u, v;
		cin >> c >> u >> v;
		if(c == 'M'){
			update(1, 1, n, v, u);
		}
		else{
			cout << get(1, 1, n, v, u) << "\n";
		}
	}
}

Compilation message (stderr)

deda.cpp: In function 'int main()':
deda.cpp:40:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...