# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
888574 | White | 원숭이와 사과 나무 (IZhO12_apple) | C++14 | 145 ms | 83864 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
bitset<4000000000>onlyOne,hasOne;
void update_tree(int l,int r,int L,int R,int now){
//cout<<now<<" "<<l<<" "<<r<<endl;
if(l>R || r<L || onlyOne[now]==1)return ;
if(l>=L && r<=R){
onlyOne[now]=1;
hasOne[now]=1;
return;
}
int mid=(l+r)/2;
update_tree(l,mid,L,R,now*2+1);
update_tree(mid+1,r,L,R,now*2+2);
if(onlyOne[now*2+1]==1 && onlyOne[now*2+2]==1)onlyOne[now]=1;
if(hasOne[now*2+1]==1 || hasOne[now*2+2]==1 || onlyOne[now*2+2]==1 || onlyOne[now*2+1]==1)hasOne[now]=1;
}
int ans_tree(int l,int r,int L,int R,int now){
if(l>R || r<L || hasOne[now]==0)return 0;
if(onlyOne[now]==1){
//cout<<l<<" )_( "<<r<<endl;
return (min(r,R)-max(l,L)+1);
}
int mid=(l+r)/2;
return ans_tree(l,mid,L,R,now*2+1)+ans_tree(mid+1,r,L,R,now*2+2);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |