hiho week 177 register

Ended

Participants:499

Verdict:Accepted
Score:100 / 100
Submitted:2017-11-24 00:35:13

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<math.h>  
#include<stdio.h>  
  
#define MAXN 1050000  
struct node{  
    int x,y;  
}tree[MAXN];  
int n,m,ans;  
int x3,y3,x4,y4;  
  
void build(int x,int y,int k,int n)  
{  
    tree[k].x=x,tree[k].y=y;  
    if(n==1) return;  
  
    if(n==2){  
        build(x+2,y+2,2*k+1,n-1); ///right  
        build(x+2,y-2,2*k,n-1);   ///left  
    }  
    else{  
        build(x+3*pow(2,n-3),y+3*pow(2,n-3),2*k+1,n-1); ///right  
        build(x+3*pow(2,n-3),y-3*pow(2,n-3),2*k,n-1);   ///left  
    }  
}  
  
void Search(int k)  
{  
    if(tree[k].x>x4) return ;  
    if(k>((1<<n)-1)) return ;  
    if(tree[k].x>=x3&&tree[k].x<=x4&&tree[k].y>=y3&&tree[k].y<=y4) ans++;  
  
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX