複習線段樹,把notonlysuccess上面的推薦題目都刷一遍。
需求:單點更新,區間求和。
#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;
#pragma pack(4)
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x7f7f7f7f;
const __int64 inf = 0x7f7f7f7f7f7f7f7fll;
#define loop(a,n) \
for(int i=0;n>i;i++) \
coutfor(int j=0;m>j;j++) \
cout#define less(a,b) (((b)-(a))>eps)
#define greq(a,b) (((a)-(b))>-eps)
#define leeq(a,b) (((b)-(a))>-eps)
#define equl(a,b) (fabs((a)-(b))(b)?(a):(b))
#define lmin(a,b) ((a)<(b)?(a):(b))
#define fmax(a,b) (gret(a,b)?(a):(b))
#define fmin(a,b) (less(a,b)?(a):(b))
const int maxv = 50002;
char o[10];
int tcase,times=1,u,w,n;
int sum[maxv<<2],lazy[maxv<<2];
#define lc(i) ((i)<<1)
#define rc(i) ((i)<<1|1)
void up(int i)
void down(int i)
void change(int x,int y,int w,int l=1,int r=n,int i=1)
else
getchar();
printf("case %d:\n",times++);
while(scanf("%s",o),strcmp(o,"end"))
}return 0;
}
hdu 1166 敵兵布陣
這是一道線段樹里最簡單的一類題目了,單點更新型別!include define lson l m rt 1 define rson m 1 r rt 1 1 const int maxx 55555 int sum maxx 2 void pushup int rt void build int l...
hdu 1166 敵兵布陣
線段樹的模版 沒什麼思想 include include include include include include include include include include include include include define ll long long define vi vec...
HDU 1166 敵兵布陣
description lily 特別喜歡養花,但是由於她的花特別多,所以照料這些花就變得不太容易。她把她的花依次排成一行,每盆花都有乙個美觀值。如果lily把某盆花照料的好的話,這盆花的美觀值就會上公升,如果照料的不好的話,這盆花的美觀值就會下降。有時,lily想知道某段連續的花的美觀值之和是多少...