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 <cstring>
#include <algorithm>
using namespace std;
struct data{
int l,r,edge;
};
data tree[8000];
int tn,n,flag;
void make_tree(int a){
if(a>=tn) return;
make_tree(a*2); make_tree(a*2+1);
if(tree[a*2].l==-1) return;
else if(tree[a*2+1].l==-1){ tree[a]=tree[a*2]; return; }
tree[a].l=tree[a*2].l; tree[a].r=tree[a*2+1].r; tree[a].edge=(tree[a*2].r-tree[a*2].l+1)*(tree[a*2+1].r-tree[a*2+1].l+1);
}
void initialize(int N){
int i;
n=N; tn=1;
memset(tree,-1,sizeof(tree));
while(tn<n) tn*=2;
for(i=tn;i<tn+n;i++) tree[i].l=tn-i+1,tree[i].r=tn-i+1;
make_tree(1);
}
int islink(int a,int u,int v){
int res;
if(a>=tn) return 0;
if(tree[a].l<=u && tree[a].r>=v){
res=islink(a*2,u,v)+islink(a*2+1,u,v);
if(res>0) return 1;
if(tree[a].edge==1){ flag=1; return 1; }
tree[a].edge--; flag=0; return 1;
}
else return 0;
}
int hasEdge(int u, int v){
if(u>v) swap(u,v);
int a=islink(1,u,v);
return flag;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |