摘要: 最长公共上升子序列:O(n*m)的算法; 1 #include 2 #include 3 #define maxn 1000 4 using namespace std; 5 int a[maxn],b[maxn],f[maxn]; 6 int main() 7 { 8 int t,n,m; 9 scanf("%d",&t);10 while(t--)11 {12 memset(f,0,sizeof f);13 int ans=0;14 scanf("%d",&n);15 for(int i=0;i... 阅读全文
posted @ 2013-11-14 19:54 Yours1103 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 初识后缀自动机;推荐学习:http://blog.sina.com.cn/s/blog_7812e98601012dfv.html 1 #include 2 #include 3 #include 4 #define maxn 600009 5 using namespace std; 6 7 char s[maxn]; 8 9 struct node10 {11 int l;12 node *ch[28],*fail;13 } pool[maxn],*head,*tail;14 int top;15 void add(int x)16 {17 node *p=&p... 阅读全文
posted @ 2013-11-14 19:35 Yours1103 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 利用单调性求最短连续子序列的和大于等于s; 1 #include 2 #include 3 #include 4 #define maxn 100009 5 using namespace std; 6 7 int sum[maxn]; 8 int main() 9 {10 int n,s,x;11 while(scanf("%d%d",&n,&s)!=EOF)12 {13 memset(sum,0,sizeof sum);14 int ans=n+1;15 for(int i=1;isum[i]-s)continue;... 阅读全文
posted @ 2013-11-14 17:28 Yours1103 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 扫描线,注意这个题目要求的是开区间; 1 #include 2 #include 3 #define maxn 100009 4 using namespace std; 5 6 void update(int x,int a,int w,double& l,double& r) 7 { 8 if(a==0) 9 {10 if(x=w)r=l-1;11 }12 else if(a>0)13 {14 l=max(l,-(double)x/a);15 r=min(r,(double)(w-x)/a);16 ... 阅读全文
posted @ 2013-11-14 17:16 Yours1103 阅读(194) 评论(0) 推荐(0) 编辑