/* 线段树 */ #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int64; //typedef __int64 int64; typedef pair PII; #define MP(a,b) make_pair((a),(b)) const int maxn = 10005; const int inf = 0x7fffffff; const double pi=acos(-1.0); const double eps = 1e-8; #define L(x) (x<<1) #define R(x) (x<<1|1) struct Tree{ int l,r,id,val; }tree[ maxn<<2 ]; int a[ maxn ]; void build( int L,int R,int n ){ tree[ n ].l = L; tree[ n ].r = R; if( L==R ){ tree[ n ].id = L; tree[ n ].val = a[ L ]; return ; } //tree[ n ].val = 0; int mid = (L+R)/2; build( L,mid,L(n) ); build( mid+1,R,R(n) ); if( tree[ L(n) ].val