# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
619971 | AbdelmagedNour | Fortune Telling 2 (JOI14_fortune_telling2) | C++17 | 532 ms | 31072 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;
struct SegTreeMax{
int tree[1<<21];
int sz;
void init(int n){
sz=1;
while(sz<n)sz*=2;
memset(tree,-1,2*sz*sizeof(tree[0]));
}
void update(int l,int r,int p,int idx,int val){
if(l==r){
tree[p]=val;
return;
}
int md=(l+r)>>1;
if(md>=idx)update(l,md,p*2+1,idx,val);
else update(md+1,r,p*2+2,idx,val);
tree[p]=max(tree[p*2+1],tree[p*2+2]);
}
void update(int idx,int val){
update(0,sz-1,0,idx,val);
}
int query(int l,int r,int p,int l_q,int r_q){
if(l>r_q||r<l_q)return -1;
if(l>=l_q&&r<=r_q)return tree[p];
int md=(l+r)>>1;
int ch1=query(l,md,p*2+1,l_q,r_q);
int ch2=query(md+1,r,p*2+2,l_q,r_q);
return max(ch1,ch2);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |