05 2012 档案
【HDU】3265 Posters
摘要:1 #include<cstdio> 2 #include<cstring> 3 #include<cstdlib> 4 #define MAXN 50010 5 typedef __int64 LL; 6 struct Line 7 { 8 int left,right,high,flag; 9 }; 10 struct node 11 { 12 int cover,len; 13 }; 14 Line p[MAXN<<3]; 15 node tree[MAXN<<5]; 16 int cnt,x[MAXN<<3]; 1
阅读全文
【HDU】1542 Atlantis
摘要:1 #include<cstdio> 2 #include<cstring> 3 #include<cstdlib> 4 #include<cmath> 5 #define EPS 1e-9 6 #define MAXN 210 7 struct Line 8 { 9 double left,right,high; 10 int flag; 11 }; 12 struct node 13 { 14 int cover; 15 double len; 16 }; 17 node tree[MAXN<<2]; 18 Line p[MAXN
阅读全文
【HDU】3911 Black And White
摘要:1 #include<cstdio> 2 #define MAXN 100010 3 struct node 4 { 5 int left0,right0,v0,left1,right1,v1,lazy; 6 }; 7 node tree[MAXN<<2]; 8 inline int MAX(int x,int y) 9 { 10 return x>y?x:y; 11 } 12 inline int MIN(int x,int y) 13 { 14 return x>y?y:x; 15 } 16 inline void swap(int &x,int
阅读全文
【UESTC】1425 Another LCIS
摘要:1 #include<cstdio> 2 #define MAXN 100010 3 struct node 4 { 5 int left,right,res,add,x,y; 6 }; 7 node tree[MAXN<<2]; 8 int n; 9 inline int MAX(int x,int y) 10 { 11 return x>y?x:y; 12 } 13 inline int MIN(int x,int y) 14 { 15 return x>y?y:x; 16 } 17 inline void PushUp(int mid,int ...
阅读全文
【HDU】3308 LCIS
摘要:1 #include<cstdio> 2 #define MAXN 100010 3 struct node 4 { 5 int left,right,val; 6 }; 7 int a[MAXN]; 8 node tree[MAXN<<2]; 9 inline int MAX(int x,int y)10 {11 return x>y?x:y;12 }13 inline int MIN(int x,int y)14 {15 return x>y?y:x;16 }17 inline void PushUp(int mid,int L,int R,int rt
阅读全文
【FOJ】1968 Twinkling lights III
摘要:1 #include<cstdio> 2 #define MAXN 500010 3 struct node 4 { 5 int sum; 6 int v1,v0; 7 int left0,left1; 8 int right0,right1; 9 }; 10 node tree[MAXN<<2]; 11 int cover[MAXN<<2],lazy[MAXN<<2]; 12 inline int MAX(int x,int y) 13 { 14 return x>y?x:y; 15 } 16 inline int MIN(int ...
阅读全文
【HDU】3397 Sequence operation
摘要:1 #include<cstdio> 2 #define MAXN 100010 3 struct node 4 { 5 int sum; 6 int v0,v1; 7 int left0,left1; 8 int right0,right1; 9 }; 10 node tree[MAXN<<2]; 11 int lazy[MAXN<<2],cover[MAXN<<2]; 12 inline int MAX(int x,int y) 13 { 14 return x>y?x:y; 15 } 16 inline int MIN(int ...
阅读全文
【HDU】1540 Tunnel Warfare
摘要:1 #include<cstdio> 2 #include<stack> 3 #define MAXN 50010 4 #define MAX(a,b) ((a)>(b)?(a):(b)) 5 using namespace std; 6 stack<int>st; 7 struct node 8 { 9 int left,right; 10 }; 11 node tree[MAXN<<2]; 12 void Build(int L,int R,int rt) 13 { 14 tree[rt].left=tree[rt].right=R-L
阅读全文
【POJ】3667 Hotel
摘要:1 #include<cstdio> 2 #define MAX(a,b) ((a)>(b)?(a):(b)) 3 #define MAXN 50010 4 struct node 5 { 6 int right,left,val; 7 }; 8 node tree[MAXN<<2]; 9 int lazy[MAXN<<2]; 10 void Build(int L,int R,int rt) 11 { 12 lazy[rt]=-1; 13 tree[rt].left=tree[rt].right=tree[rt].val=R-L+1; 14 ...
阅读全文
【HDU】4107 Gangster
摘要:1 #include<cstdio> 2 #include<cstring> 3 #define MAXN 200010 4 int big[MAXN<<2],small[MAXN<<2],lazy[MAXN<<2]; 5 int n,m,p; 6 inline int MIN(int x,int y) 7 { 8 return x>y?y:x; 9 } 10 inline int MAX(int x,int y) 11 { 12 return x>y?x:y; 13 } 14 inline void PushUp(int
阅读全文
【HDU】4046 Panda
摘要:1 #include<cstdio> 2 #define MAX(a,b) ((a)>(b)?(a):(b)) 3 #define MAXN 50010 4 char s[MAXN]; 5 int tree[MAXN<<2]; 6 inline void PushUp(int rt) 7 { 8 tree[rt]=tree[rt<<1]+tree[rt<<1|1]; 9 } 10 inline bool OK(int i) 11 { 12 return s[i]=='w'&&s[i+1]=='b
阅读全文
【ZOJ】3279 Ants
摘要:1 #include<cstdio> 2 #define MAXN 100010 3 int tree[MAXN<<2]; 4 inline void PushUp(int rt) 5 { 6 tree[rt]=tree[rt<<1]+tree[rt<<1|1]; 7 } 8 void Build(int L,int R,int rt) 9 {10 if(L==R)11 scanf("%d",&tree[rt]);12 else13 {14 int mid=(L+R)>>1;15 Build(L,mid,r
阅读全文
【HDU】3074 Multiply game
摘要:1 #include<cstdio> 2 typedef __int64 LL; 3 #define MAXN 50010 4 #define MOD 1000000007 5 LL tree[MAXN<<2]; 6 inline void PushUp(int rt) 7 { 8 tree[rt]=tree[rt<<1]*tree[rt<<1|1]; 9 tree[rt]%=MOD;10 }11 void Build(int L,int R,int rt)12 {13 if(L==R)14 scanf("%I64d",&am
阅读全文
【POJ】2352 Stars
摘要:1 #include<cstdio> 2 #include<cstring> 3 #define MAXN 32010 4 int tree[MAXN<<2],ans[MAXN]; 5 inline void PushUp(int rt) 6 { 7 tree[rt]=tree[rt<<1]+tree[rt<<1|1]; 8 } 9 void Update(int x,int L,int R,int rt)10 {11 if(L==R)12 tree[rt]++;13 else14 {15 int mid=(L+R)>>1
阅读全文
【POJ】2777 Count Color
摘要:1 #include<cstdio> 2 #include<cstring> 3 #define MAXN 100010 4 int cnt; 5 struct node 6 { 7 int bit,val; 8 }; 9 node tree[MAXN<<2];10 inline void swap(int &x,int &y)11 {12 int temp=x;13 x=y;14 y=temp;15 }16 inline void PushUp(int rt)17 {18 tree[rt].bit=tree[rt<<1].bit
阅读全文
【ZOJ】1610 Count the Colors
摘要:1 #include<cstdio> 2 #include<cstring> 3 #define MAXN 8010 4 int tree[MAXN<<2],color[MAXN],ans[MAXN]; 5 inline void PushDown(int rt) 6 { 7 if(tree[rt]!=-1) 8 { 9 tree[rt<<1]=tree[rt<<1|1]=tree[rt];10 tree[rt]=-1;11 }12 }13 void Update(int x,int y,int val,int L,int R,int
阅读全文
【Codeforces】159C String Manipulation 1.0
摘要:1 #include<cstdio> 2 #include<cstring> 3 #define MAXN 200010 4 char s[MAXN]; 5 int tree[26][MAXN<<2]; 6 bool vis[MAXN]; 7 inline void PushUp(int t,int rt) 8 { 9 tree[t][rt]=tree[t][rt<<1]+tree[t][rt<<1|1];10 }11 void Update(int t,int x,int L,int R,int rt)12 {13 if(L==R)
阅读全文
【POJ】3225 Help with Intervals
摘要:1 #include<cstdio> 2 #include<cstring> 3 #define MAXN 131080 4 #define INF 987654321 5 int lazy[MAXN<<2],cover[MAXN<<2]; 6 bool vis[MAXN<<1]; 7 inline void FXOR(int rt) 8 { 9 if(cover[rt]!=-1) 10 { 11 cover[rt]^=1; 12 lazy[rt]=0; 13 } 14 else 15 lazy...
阅读全文
【POJ】2528 Mayor's posters
摘要:1 #include<cstdio> 2 #include<cstring> 3 #include<cstdlib> 4 #define MAXN 50010 5 struct node 6 { 7 int x,y; 8 }; 9 node a[MAXN],p[MAXN]; 10 int cmp(const void *a,const void *b) 11 { 12 return (*(node *)a).x-(*(node *)b).x; 13 } 14 int ans,tree[MAXN<<2]; 15 bool vis[MAXN]; 16
阅读全文
【POJ】3264 Balanced Lineup
摘要:1 #include<cstdio> 2 #define MAXN 50010 3 #define INF 987654321 4 int a[MAXN<<2],b[MAXN<<2]; 5 inline int MAX(int x,int y) 6 { 7 return x>y?x:y; 8 } 9 inline int MIN(int x,int y)10 {11 return x>y?y:x;12 }13 inline void PushUp(int rt)14 {15 a[rt]=MAX(a[rt<<1],a[rt<<
阅读全文
【POJ】4047 Garden
摘要:1 #include<cstdio> 2 #define MAXN 200010 3 #define INF 987654321 4 int a[MAXN],s[MAXN],tree[MAXN<<2],lazy[MAXN<<2],k; 5 inline int MAX(int x,int y) 6 { 7 return x>y?x:y; 8 } 9 inline int MIN(int x,int y) 10 { 11 return x>y?y:x; 12 } 13 inline void swap(int &x,int &y)
阅读全文
【POJ】3468 A Simple Problem with Integers
摘要:1 #include<cstdio> 2 typedef __int64 LL; 3 #define MAXN 100010 4 LL tree[MAXN<<2],lazy[MAXN<<2]; 5 inline void PushUp(int rt) 6 { 7 tree[rt]=tree[rt<<1]+tree[rt<<1|1]; 8 } 9 void Build(int L,int R,int rt)10 {11 lazy[rt]=0;12 if(L==R)13 scanf("%I64d",&tree[
阅读全文
【HDU】1698 Just a Hook
摘要:1 #include<cstdio> 2 #include<cstring> 3 #define MAXN 100010 4 int tree[MAXN<<2],lazy[MAXN<<2]; 5 inline void PushUp(int rt) 6 { 7 tree[rt]=tree[rt<<1]+tree[rt<<1|1]; 8 } 9 void Build(int L,int R,int rt)10 {11 lazy[rt]=0;12 if(L==R)13 tree[rt]=1;14 else15 {16 int.
阅读全文
【POJ】2828 Buy Tickets
摘要:1 #include<cstdio> 2 #define MAXN 200010 3 int tree[MAXN<<2],pos[MAXN],val[MAXN],ans[MAXN]; 4 void Build(int L,int R,int rt) 5 { 6 tree[rt]=R-L+1; 7 if(L!=R) 8 { 9 int mid=(L+R)>>1;10 Build(L,mid,rt<<1);11 Build(mid+1,R,rt<<1|1);12 }13 }14 int Update(int x,in...
阅读全文
【HDU】2795 Billboard
摘要:1 #include<cstdio> 2 #define MAXN 200010 3 #define MIN(a,b) ((a)>(b)?(b):(a)) 4 #define MAX(a,b) ((a)>(b)?(a):(b)) 5 int w,tree[MAXN<<2]; 6 inline void PushUp(int rt) 7 { 8 tree[rt]=MAX(tree[rt<<1],tree[rt<<1|1]); 9 }10 void Build(int L,int R,int rt)11 {12 if(L==R)13 tr
阅读全文
【HDU】1394 Minimum Inversion Number
摘要:1 #include<cstdio> 2 #include<cstring> 3 #define MIN(a,b) ((a)>(b)?(b):(a)) 4 #define MAXN 5010 5 int tree[MAXN<<2],a[MAXN]; 6 inline void PushUp(int rt) 7 { 8 tree[rt]=tree[rt<<1]+tree[rt<<1|1]; 9 }10 void Update(int x,int L,int R,int rt)11 {12 if(L==R)13 tree[rt]=1
阅读全文
【HDU】1166 敌兵布阵
摘要:1 #include<cstdio> 2 #include<cstring> 3 #define MAXN 50010 4 int tree[MAXN<<2]; 5 inline void PushUp(int rt) 6 { 7 tree[rt]=tree[rt<<1]+tree[rt<<1|1]; 8 } 9 void Build(int L,int R,int rt)10 {11 if(L==R)12 scanf("%d",&tree[rt]);13 else14 {15 int mid=(L+R)&
阅读全文