随笔分类 -  ACM_线段树

摘要:http://poj.org/problem?id=3468代码:#include#include#define maxn 100010struct node{ int l,r; __int64 sum,p;}tree[maxn*4];__int64 value[maxn];void build(int l,int r,int v){ tree[v].l=l; tree[v].r=r; tree[v].p=0; if(l==r) { tree[v].sum=value[l]; return ; } int mid... 阅读全文
posted @ 2013-10-27 19:23 清风旋叶 阅读(171) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4046非线段树的方法,纯模拟。(AC)#include #include #include using namespace std;const int maxn = 50000+5;char str[maxn];int vis[5];int dp[maxn];int main(){ int t,ncas= 1; scanf("%d",&t); while( t-- ) { printf("Case %d:\n",ncas++); int n,m; ... 阅读全文
posted @ 2013-10-22 19:52 清风旋叶 阅读(181) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1754代码:#include#include#includeusing namespace std;#define maxn 200005int tree[4*maxn];void build(int left,int right,int root){ if(left==right) { scanf("%d",&tree[root]); } else { int mid=(left+right)/2; build(left,mid,ro... 阅读全文
posted @ 2013-10-22 19:42 清风旋叶 阅读(222) 评论(0) 推荐(0)