# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
676149 | Trisanu_Das | Deda (COCI17_deda) | C++17 | 82 ms | 3356 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 <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 |
---|---|---|---|---|
Fetching results... |