上一页 1 2 3 4 5 6 7 ··· 12 下一页

2012年10月1日

ZOJ Monthly, September 2012 Matrix Transformer

摘要: 把U看成象棋中的车,这样问题转化成:在棋盘上给出若干个车,问能否选出n个车,使得他们之间不会相互攻击。设横轴为X,纵轴为Y,每个车会独占一个X,一个Y,这样问题成转化成:是否存在每个X都可以独占一个Y。到这里,有点二分图基础的就知道是裸二分图了。View Code #include<stdio.h>#include<string.h>#include<vector>#include<iostream>using namespace std;const int maxn = 205;char str[maxn];vector<int>a 阅读全文

posted @ 2012-10-01 21:41 aigoruan 阅读(207) 评论(0) 推荐(0)

2012年9月30日

Can you answer these queries V gss5

摘要: 在gss3的基础上再YY一下吧~~~http://www.spoj.pl/problems/GSS5/View Code #include<stdio.h>#include<string.h>#include<iostream>#define lson rt<<1#define rson rt<<1|1using namespace std;const int maxn = 10005;int sum[maxn],bs[maxn];int n,m;struct nd{ int sum,lx,rx,mx;}as[maxn<< 阅读全文

posted @ 2012-09-30 11:29 aigoruan 阅读(176) 评论(0) 推荐(0)

2012年9月29日

spoj 2713 Can you answer these queries IV

摘要: http://www.spoj.pl/problems/GSS4/题意:给一个数列,有两个操作:0 L,R,把区间[L,R]内的数开平方。1 L,R,求区间[L,R]的和。思路:因为一个1e18的数开方8次后必为1,所以时间复杂度为O(8*n+n*log(n))。View Code #include<stdio.h>#include<string.h>#include<iostream>#include<math.h>#define LL long long#define lson rt<<1#define rson rt<&l 阅读全文

posted @ 2012-09-29 21:09 aigoruan 阅读(279) 评论(0) 推荐(0)

Can you answer these queries III

摘要: http://www.spoj.pl/problems/GSS3/题意:求区间的最大连续序列和,带修改。思路:和GSS1差不多,多一个更新而已。View Code #include<stdio.h>#include<string.h>#include<iostream>#define lson rt<<1#define rson rt<<1|1#define LL long longusing namespace std;const LL maxn = 50005;LL bs[maxn],n,m;struct nd{ LL lx,rx 阅读全文

posted @ 2012-09-29 18:14 aigoruan 阅读(182) 评论(0) 推荐(0)

2012年9月23日

2012 ACM/ICPC Asia Regional Hangzhou Online Super Mario hdu 4417

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4417思路:线段树+二分裸奔~~~View Code #include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>using namespace std;const int maxn = 100005;int as[23][maxn*4];int n,m;void build(int rt,int l,int r,int d){ int md=(l+r)>>1; fo 阅读全文

posted @ 2012-09-23 18:11 aigoruan 阅读(342) 评论(5) 推荐(0)

2012年9月22日

2012 2012 ACM/ICPC Asia Regional Jinhua Online Sum

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4407思路:问题转化:给定n,p,求n内和p互质的数的和。剩下的暴力。关键代码是队友写的:View Code #include<stdio.h>#include<string.h>#include<algorithm>#include<iostream>#include<map>#include<stdio.h>#include<string.h>#include<stdlib.h>#include<algo 阅读全文

posted @ 2012-09-22 18:36 aigoruan 阅读(243) 评论(0) 推荐(0)

2012 2012 ACM/ICPC Asia Regional Jinhua Online Family Name List

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4409思路:建树后,就是裸LCA了,代码写得不好~~~View Code #include<stdio.h>#include<string.h>#include<string>#include<vector>#include<iostream>#include<algorithm>#include<map>using namespace std;const int maxn = 30003;int fa[maxn],pre[m 阅读全文

posted @ 2012-09-22 18:30 aigoruan 阅读(217) 评论(0) 推荐(0)

2012年9月18日

uva Permutation Transformer

摘要: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3073题意:原始序列为1,2,3,4,,,,n;现有操作:L,R将区间[L,R]割下来,反序后放到序列的最后。思路:splay暴力splay很容易完成区间切割,区间插入。 阅读全文

posted @ 2012-09-18 10:43 aigoruan 阅读(120) 评论(0) 推荐(0)

2012年9月17日

SPOJ 1043 Can you answer these queries I(GSS1 线段树)

摘要: http://www.spoj.pl/problems/GSS1/题意:给一个序列,求区间的最大连续子序列和。思路:维护三个值区间的最大连续和,左端连续的最大和。右端连续的最大连续和。查询的时候先看左右两个区间的最大连续和,再看两区间交界处的最大连续和。(参考:http://blog.csdn.net/acm_cxlove/article/details/7982444)View Code #include<stdio.h>#include<string.h>#include<iostream>using namespace std;const int ma 阅读全文

posted @ 2012-09-17 14:04 aigoruan 阅读(160) 评论(0) 推荐(0)

uva Array Transformer

摘要: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3154题意:给一个序列,然后是操作:L,R,V,P:求区间[L,R]中小于V的个数k,然后更新 P位置的值为k*u/(R-L+1)。输出最后的序列。思路:线段树 套 sbt.View Code #include<stdio.h>#include<string.h>#include<iostream>#include<stdlib.h> 阅读全文

posted @ 2012-09-17 13:06 aigoruan 阅读(175) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 ··· 12 下一页

导航