2013年8月2日
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4614线段树 , 中间有二分操作#include #include #include #include using namespace std;#define ls (rt>1)const int maxn = 50050;struct node { int l , r; int sum; int lazy;}t[maxn mid) return query(rs,l,r); else if(r mid) change(rs , l , r , val); else if(r ... 阅读全文
posted @ 2013-08-02 17:16 tobec 阅读(186) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4628#include #include #include #include using namespace std;bool is[1=0;i--) { f[i] = (1<<29); for(int j=i+1;j<=n;j = (j+1)|i) { if(is[j-i]) { f[i] = min(f[i] , f[j] + 1); } } } printf("%d\n" , ... 阅读全文
posted @ 2013-08-02 17:13 tobec 阅读(177) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4638线段树 离线处理题意为询问一段区间里的数能组成多少段连续的数。先考虑从左往右一个数一个数添加,考虑当前添加了i-1个数的答案是x,那么添加完i个数后的答案是多少?可以看出,是根据a[i]-1和a[i]+1是否已经添加而定的,如果a[i]-1或者a[i]+1已经添加一个,则段数不变,如果都没添加则段数加1,如果都添加了则段数减1。设v[i]为加入第i个数后的改变量,那么加到第x数时的段数就是sum{v[i]}(1#include #include #include using namespace std; 阅读全文
posted @ 2013-08-02 13:58 tobec 阅读(227) 评论(0) 推荐(0) 编辑
2013年8月1日
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4635强连通分量缩点之后+简单计算,具体见代码#include #include #include #include using namespace std;const int maxn = 100100;struct Edge { int v , next; Edge () {} Edge (int v , int next) : v(v) , next(next) {};}edge[maxn ans) ans = tt; } ans -= mm; ... 阅读全文
posted @ 2013-08-01 22:44 tobec 阅读(164) 评论(0) 推荐(0) 编辑
2013年7月31日
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4604ans = max( 以i开头的最长不下降子序列+以i开头的最长不上升子序列-min(以i开头的最长不下降子序列中val[i]的个数,以i开头的最长不上升子序列中val[i]的个数) )但是LIS求的是以i结尾的,所以将数组翻转#include #include #include #include #include using namespace std;const int maxn = 100100;int val[maxn] , n;void DP(int num[],int dp[],int sa 阅读全文
posted @ 2013-07-31 23:14 tobec 阅读(162) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1000虽然觉得放在这里有点水的意思,但这毕竟是我学ACM的第一个代码,通过这个代码,我了解了ACM竞赛的标准输入输出格式。#include int a , b;int main() { while(~scanf("%d%d",&a ,&b)) { printf("%d\n" , a+b); } return 0;} 阅读全文
posted @ 2013-07-31 22:53 tobec 阅读(135) 评论(0) 推荐(0) 编辑