#include<iostream>
using namespace std;
int n, q, i, x, p, sol;
char t;
int aint[400005];
void update(int nod, int st, int dr, int p, int val){
if(st == dr){
aint[nod] = val;
}
else{
int mid = (st + dr) / 2;
if(p <= mid){
update(2 * nod, st, mid, p, val);
}
else{
update(2 * nod + 1, mid + 1, dr, p, val);
}
aint[nod] = min(aint[2 * nod], aint[2 * nod + 1]);
}
}
void query(int nod, int st, int dr, int p, int u, int val){
if(sol != -1){
return;
}
if(st == dr){
sol = st;
return;
}
int mid = (st + dr) / 2;
if(p <= mid && aint[2 * nod] <= val){
query(2 * nod, st, mid, p, u, val);
}
if(u > mid && aint[2 * nod + 1] <= val){
query(2 * nod + 1, mid + 1, dr, p, u, val);
}
}
int main(){
cin>> n >> q;
for(i = 1; i <= 4 * n; i++){
aint[i] = 10001000000;
}
for(; q; q--){
cin>> t >> x >> p;
if(t == 'M'){
update(1, 1, n, p, x);
}
else{
sol = -1;
query(1, 1, n, p, n, x);
cout<< sol <<"\n";
}
}
}
Compilation message
deda.cpp: In function 'int main()':
deda.cpp:40:19: warning: overflow in implicit constant conversion [-Woverflow]
aint[i] = 10001000000;
^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
18 ms |
376 KB |
Output is correct |
4 |
Runtime error |
6 ms |
3704 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Correct |
679 ms |
6036 KB |
Output is correct |
6 |
Runtime error |
6 ms |
3576 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
6 ms |
3576 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |