随笔分类 -  线段树

摘要:最长公共子序列nlogn神算法,线段树换了几种姿势,怎么搞都超时,把他转换成LIS就AC了A : 3 3 1 1 2 2B : 3 2 3 1 2 1B中的每个元素在A中的位置倒序再放入B中可得 {2,1}{6,5}{2,1}{4,3}{6,5}{4,3}我们发现,B中的每一个大括号取一个数,对应A中的匹配加1,而要使A的标号递增,就把每个括号按递减顺序排列,然后对这个序列求LIS就是答案。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define maxn 200... 阅读全文
posted @ 2013-11-20 20:39 wonderzy 阅读(257) 评论(0) 推荐(0)
摘要:貌似人家都是用链表过的,我太弱了,只会用线段树,排最后了,还好1A了。。。。 1 #include 2 #include 3 #include 4 using namespace std; 5 int t,n; 6 int dp[100010]; 7 struct tree{ 8 int l,r; 9 int ans,lans,rans; 10 }a[400010];11 struct point{12 int v,x;13 }p[100010];14 int ans[100010];15 void build(int l,int r,int k){1... 阅读全文
posted @ 2013-11-11 18:21 wonderzy 阅读(222) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 #define ll long long 6 using namespace std; 7 int n,m,t,tol,tt; 8 ll f[100010]; 9 ll sum[100010]; 10 struct edge{ 11 int u,v,x; 12 ll l; 13 edge(){} 14 edge(int u,int v,ll l,int x):u(u),v(v),l(l),x(x){} 15 friend bool op... 阅读全文
posted @ 2013-11-04 23:01 wonderzy 阅读(330) 评论(0) 推荐(0)