# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145026 | alexandra_udristoiu | Deda (COCI17_deda) | C++14 | 843 ms | 8032 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
using namespace std;
int n, q, i, x, p, sol;
char t;
int aint[800005];
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |