Submission #676147

# Submission time Handle Problem Language Result Execution time Memory
676147 2022-12-29T13:50:12 Z Trisanu_Das Deda (COCI17_deda) C++17
0 / 140
67 ms 6964 KB
#include <bits/stdc++.h>
using namespace std;
 
const int mxN=2e5;
int n, q, a, b, segtree[1<<19];
char op;
 
void update(int s, int x, int i=1, int l=0, int r=n-1) {
	segtree[i]=min(x, segtree[i]);
	if(l==r) return;
	int m=(l+r)/2;
	if(s<=m) update(s, x, 2*i, l, m);
	else update(s, x, 2*i+1, m+1, r);
}
 
int query(int s, int x, int i=1, int l=0, int r=n-1) {
	if(segtree[i]>x) return -2;
	if(l==r) return l;
	int m=(l+r)/2, e = -2;
	if(s<=m) e = query(s, x, 2*i, l, m);
	if(r==-2) e = query(s, x, 2*i+1, m+1, r);
	return r;
}
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> q;
	memset(segtree, 0x3f, sizeof(segtree));
	while(q--) {
		cin >> op >> a >> b, --b;
		if(op=='M') update(b, a);
		else cout << query(b, a)+1 << "\n";
	}
}

Compilation message

deda.cpp: In function 'int query(int, int, int, int, int)':
deda.cpp:19:17: warning: variable 'e' set but not used [-Wunused-but-set-variable]
   19 |  int m=(l+r)/2, e = -2;
      |                 ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2388 KB Output isn't correct
2 Incorrect 2 ms 2376 KB Output isn't correct
3 Incorrect 3 ms 2388 KB Output isn't correct
4 Incorrect 64 ms 6964 KB Output isn't correct
5 Incorrect 61 ms 6432 KB Output isn't correct
6 Incorrect 62 ms 6760 KB Output isn't correct
7 Incorrect 67 ms 6868 KB Output isn't correct