摘要:
#include <stdio.h>int main(){ int n,a[1010],i,j,max,b[1010]; while(scanf("%d",&n),n) { for(i=1;i<=n;i++) { scanf("%d",&a[i]); b[i]=a[i]; } max=a[1]; for(i=2;i<=n;i++) { for(j=1;j<i;j++) { if(a[i]>a[j]&&b[i]<a[i]+b[j]) b[i]=a[i]+b[j]; } if(b[i] 阅读全文
摘要:
染色插入算法procedure Insert(p, l, r, a, b, c: Integer);var m: Integer;begin if Tree[p].cover <> c then begin m := (l + r) div 2; if (a = l) and (b = r) then Tree[p].cover := c else begin if Tree[p].cover >= 0 then begin Tree[p * 2].cover := Tree[p].cover; Tree[p * 2 + 1].cover := Tree[p].cover; 阅读全文
摘要:
其中的标志s用的很妙,非常精髓,标记是否是纯色,单色,是否往下递归,计算单色数据#include <iostream>#include <cstdio>using namespace std;const int MAXN=2000000;int n,m,a[MAXN+5],ans;struct tree{ int l,r; int s;}trees[MAXN*2];int max(int k,int l){ return k>l?k:l;}void buildtree(int rs,int l,int r){ //printf("%d %d %d\n&q 阅读全文
摘要:
#include <iostream>#include <cstdio>using namespace std;const int MAXN=2000000;int n,m,a[MAXN+5];struct tree{ int l,r; int v;}trees[MAXN*2];int max(int k,int l){ return k>l?k:l;}void buildtree(int rs,int l,int r){ //printf("%d %d %d\n",rs,l,r); trees[rs].l=l; trees[rs].r=r; 阅读全文