自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

BraketBN

Think, Thank, Thunk.

  • 博客(79)
  • 收藏
  • 关注

原创 【BZOJ1710】[Usaco2007 Open]Cheappal 廉价回文【区间DP】

【题目链接】经典区间DP。首先添加一个字符和删除一个字符是等价的,因为在一个位置添加一个字符,就等价与在对称回文的位置删除一个字符,删除同理。那么我们只需要考虑删除字符。设dp[l][r]表示将[l, r]改为回文串的最小代价,那么有(1)dp[l][r] = min(dp[l + 1][r] + cost[str[l]], dp[l][r - 1] + cost[str[r]

2016-05-31 18:49:52 754

原创 【BZOJ1664】[Usaco2006 Open]County Fair Events 参加节日庆祝【线段覆盖】【贪心】

【题目链接】怎么选到了这么水的题.../* Telekinetic Forest Guard */#include #include #include using namespace std;const int maxn = 10005;int n;struct _data { int l, r; bool operator < (const _da

2016-05-31 18:45:34 895

原创 【BZOJ1649】[Usaco2006 Dec]Cow Roller Coaster【背包DP】

【题目链接】设dp[i][j],表示前i个位置,花费为j,的最大有趣指数。然后类似背包一样转移。/* Telekinetic Forest Guard */#include #include #include using namespace std;const int maxn = 1005, maxm = 10005;int L, n, m, dp[maxn][ma

2016-05-31 18:06:20 806

原创 【BZOJ1643】[Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪【暴力】

【题目链接】n = a^2 + b^2 + c^2 + d^2。暴力枚举a,b,c,都是sqrt(n)级别的,然后判断d^2是否是完全平方数。/* Telekinetic Forest Guard */#include #include #include #include using namespace std;int n, m;inline int iread

2016-05-31 16:42:27 1011

原创 【BZOJ1638】[Usaco2007 Mar]Cow Traffic 奶牛交通【DAG】【拓扑排序】【DP】

【题目链接】对于一条边(u, v),经过这条边的次数为(1到u的路径个数)*(v到n的路径个数)。正反跑两次拓扑序,然后枚举边,统计答案。一开始以为(1到u的路径个数)就是经过边(u, v)的次数,结果WA啦。/* Telekinetic Forest Guard */#include #include #include #include using names

2016-05-31 16:27:54 882

原创 【BZOJ3522】[Poi2014]Hotel【DFS】

【题目链接】NOIP2014D1T2是从这个题改的吧。。题解:首先可以发现,满足条件的点对一定是“有一个中心点,三个点到中心点的距离相等,且三个点分别在不同子树中”这种情况。那么枚举中心点,然后遍历子树,统计答案。d[i]为临时数组,表示当前子树中深度为i的点有多少个。d1[i]表示,当前点已经遍历过的子树中,深度为i的点有多少个。d2[i]表示,当前点已经遍历过的子树

2016-05-31 16:05:57 931

原创 【BZOJ1584】[Usaco2009 Mar]Cleaning Up 打扫卫生【DP】

【题目链接】【hzwer的题解】维护转移位置的数组有点神。。/* Telekinetic Forest Guard */#include #include #include #include using namespace std;const int maxn = 40005, inf = 0x3f3f3f3f;int n, m, num[maxn], dp[max

2016-05-31 15:31:29 674

原创 【BZOJ1633】[Usaco2007 Feb]The Cow Lexicon 牛的词典【DP】

【题目链接】数据范围都特别小,直接暴力就可以搞了。/* Telekinetic Forest Guard */#include #include #include using namespace std;const int maxn = 605, maxl = 27, maxm = 305;int n, m, dp[maxm], wlen[maxn];char word

2016-05-31 11:48:25 944

原创 【BZOJ1576】[Usaco2009 Jan]安全路经Travel【最短路树】【树链剖分】【线段树】

【题目链接】【hzwer的题解】orz倍增求lca,根节点的深度不能从0开始。线段树手滑打跪了orz,WA1发。/* Telekinetic Forest Guard */#include #include #include #include #include #include using namespace std;typedef pair pii;c

2016-05-31 10:46:35 811

原创 【BZOJ1570】[JSOI2008]Blue Mary的旅行【最大流】

【题目链接】太神啦。【POPOQQQ的题解】/* Telekinetic Forest Guard */#include #include #include using namespace std;const int maxn = 6005, maxm = 300005, maxe = 2505, maxq = 10000, inf = 0x3f3f3f3f;int n,

2016-05-31 08:59:55 619

原创 【BZOJ4145】[AMPPZ2014]The Prices【状压DP】【背包】

【题目链接】【tunix的题解】/* Telekinetic Forest Guard */#include #include #include using namespace std;const int maxn = 105, maxm = 18, maxs = 1 << 16, inf = 0x3f3f3f3f;int n, m, dp[maxn][maxs],

2016-05-30 17:07:21 474

原创 【BZOJ3612】[Heoi2014]平衡【计数DP】【整数拆分】

【题目链接】【tunix的题解】枚举力矩和、拿走橡皮的个数,然后就变成整数拆分问题了。/* Telekinetic Forest Guard */#include #include #include using namespace std;const int maxn = 10005, maxk = 12;int n, k, p, dp[maxn * maxk][

2016-05-30 16:42:24 724

原创 【BZOJ1857】[Scoi2010]传送带【三分套三分】

【题目链接】好像是比较经典的题了。第一次在考场上写三分orz。/* Telekinetic Forest Guard */#include #include #include #include #include using namespace std;typedef double DB;const DB eps = 1e-6;struct po {

2016-05-30 15:58:36 531

原创 【BZOJ2445】最大团【推公式】【中国剩余定理】【扩展Lucas】

【题目链接】公式为:设 ans = ∑(n! / ((d!)^(n/d)*(n/d)!))则答案为m ^ ans证明:考虑现在有d * k个点,d代表每个团的点数,那么k就是个数了,记方案数为Ak。然后现在又来了d个点,记方案数为Ak+1。(即现在有n = d * (k + 1)个点)我们选择一个点,让这个点与其他的d - 1个点组成团,方案数为C(d *

2016-05-30 07:54:07 999

原创 【BZOJ1212】[HNOI2004]L语言【Trie】【暴力】

【题目链接】直接暴力就可以了,复杂度O(n*10+m*len*10)/* Telekinetic Forset Guard */#include #include #include using namespace std;const int maxn = 205, maxl = 1300005;int n, m, son[maxn][26], cnt;bool

2016-05-27 18:04:19 783

原创 【BZOJ3142】[Hnoi2013]数列【组合数学】

【题目链接】【thy_asdf的题解】/* Telekinetic Forest Guard */#include #include #include using namespace std;typedef long long LL;LL n, k, m, p;inline LL qpow(LL a, LL n) { LL res = 1; for(; n

2016-05-27 16:57:57 466

原创 【BZOJ1221】[HNOI2001] 软件开发【最小费用最大流】

【题目链接】听说是网络流24题。。【rausen的题解】/* Telekinetic Forest Guard */#include #include #include using namespace std;const int maxn = 2005, maxm = 10005, maxq = 10000, inf = 0x3f3f3f3f;int n, A, B,

2016-05-27 10:43:02 403

原创 【BZOJ2142】礼物【扩展Lucas】

【题目链接】原来那个板有问题...重新写了下。把分解质因数写挂了,WA了一次.../* Telekinetic Forest Guard */#include #include #include using namespace std;typedef long long LL;const int maxn = 10;LL w[maxn];inlin

2016-05-26 21:37:29 505

原创 【BZOJ2729】[HNOI2012]排队【组合数学】

【题目链接】还是python好用【大爷的题解】def A(n): res = 1 for i in range(1, n + 1): res *= i return resdef C(n, m): if n < m: return 0 return A(n) // A(m) // A(n - m)n, m = [int(i) for i in raw_inpu

2016-05-26 17:24:04 397

原创 【BZOJ1485】[HNOI2009]有趣的数列【Catelan数】【线性筛】

【题目链接】这个质因数分解劲啊【xkui的题解】/* Telekinetic Forest Guard */#include #include #include using namespace std;typedef long long LL;const int maxn = 2000005;int n, m, p, prime[maxn], mn[maxn]

2016-05-26 16:41:18 607

原创 【POJ2187】Beauty Contest【旋转卡壳】

【题目链接】学习一发旋转卡壳。/* Telekinetic Forest Guard */#include #include #include using namespace std;const int maxn = 50005;int n, m;struct Vector { int x, y; Vector(int a = 0, int b = 0)

2016-05-26 15:16:22 416

原创 【BZOJ4397】[Usaco2015 dec]Breed Counting【前缀和】【或莫队】【或线段树】【或可持久化线段树】

【题目链接】数据结构学多了,看到题解发现3个前缀和就搞定了。弱智+2另外也可以线段树,也可以3个主席树。。。莫队:/* Telekinetic Forest Guard */#include #include #include using namespace std;const int maxn = 100005, maxsqrtn = 316;i

2016-05-25 19:01:00 520

原创 【BZOJ1197】[HNOI2006]花仙子的魔法【递推】

【题目链接】【VFK的题解】边界条件可以用样例推出来。首先m = 0时是1(即空空间)然后n = 1时是m * 2(用样例画一画)由递推式可以得到n = 0时是2。/* Telekinetic Forest Guard */#include #include #include using namespace std;typedef long long LL;

2016-05-24 17:41:01 443

原创 【BZOJ4044】[Cerc2014] Virus synthesis【回文自动机】

【题目链接】题解待补/* Telekinetic Forest Guard */#include #include #include using namespace std;const int maxn = 100005, maxq = maxn;int n, q[maxq], ans, dp[maxn], id[26];struct _ptree { in

2016-05-24 17:18:41 696

原创 【BZOJ1243】[Seerc2007]Showstopper【二分】

【题目链接】同【BZOJ1271】但是读入是NOI难度。#include #include #include using namespace std;typedef long long LL;const int maxn = 200005;int n;char str[10000];struct _data { int s, e, d;} p[maxn];

2016-05-24 16:48:37 390

原创 【BZOJ3144】[Hnoi2013]切糕【最小割】

【题目链接】学习一发建图。这篇题解比较详细【zarxdy34的题解】/* Telekinetic Forest Guard */#include #include #include using namespace std;const int maxg = 45, maxn = 70005, maxm = 150005, maxq = 100000, inf = 0x3f3

2016-05-24 15:36:37 1286

原创 【BZOJ1486】[HNOI2009]最小圈【SPFA判负环】【01分数规划】

【题目链接】没写过dfs的spfa,写一发。01分数规划裸题。/* Telekinetic Forest Guard */#include #include #include using namespace std;typedef double DB;const int maxn = 3005, maxm = 10005;const DB inf = 1

2016-05-24 11:46:24 589

原创 【BZOJ3143】[Hnoi2013]游走【高斯消元】【期望DP】【贪心】

【题目链接】比较经典的模型。先高斯消元求出经过每个点的期望次数,每条边经过的期望次数为两个端点经过的期望次数除以各自的度数。然后按照经过次数贪心编号。注意走到n点之后不会再继续走了。/* Telekinetic Forest Guard */#include #include #include #include using namespace std;typ

2016-05-24 10:44:46 536

原创 【BZOJ1996】[Hnoi2010]chorus 合唱队【区间DP】

【题目链接】手画一下样例就有点感觉了。一开始定了二维的状态,发现答案跑不对,后来意识到需要第三维,表示当前区间最后一个填的数是最左边的还是最右边的,然后就可以转移了。/* Telekinetic Forest Guard */#include #include #include using namespace std;const int maxn = 1005,

2016-05-24 08:49:36 371

原创 【BZOJ2733】[HNOI2012]永无乡【启发式合并】【Splay】

【题目链接】合并时候启发式合并就可以了。注意第9个点第99999个合并操作连接了0 0...调了好长时间= =/* Telekinetic Forest Guard */#include #include #include using namespace std;const int maxn = 100005;int n, m;int son[maxn][2],

2016-05-23 07:48:31 1095

原创 【BZOJ1196】[HNOI2006]公路修建问题【二分】【并查集】

【题目链接】二分最大边权,把不大于mid的边做个生成树。因为只要保证最大值不超过mid即可,具体边权、边权总和无所谓的。/* Telekinetic Forest Guard */#include #include #include using namespace std;const int maxn = 10005, maxm = 20005;int n,

2016-05-20 15:22:09 438

原创 【BZOJ1483】[HNOI2009]梦幻布丁【启发式合并】【Set】

【题目链接】把每个颜色的下标存到set里。考虑合并两个颜色,每次把size小的颜色合并到size大的颜色。但是考虑下面这情况,比如现在要把1刷成2,但是1的size比2的size大,这时我们仍把2合并到1,那么以后对颜色2的操作,我们就要对颜色1进行了。所以我们开一个数组fa[u],存的是颜色u实际对应的颜色。/* Telekinetic Forest Guard */

2016-05-20 15:02:41 452

原创 【BZOJ2326】[HNOI2011]数学作业【矩阵快速幂】

【题目链接】原来矩阵快速幂还可以分段玩。/* Telekinetic Forest Guard */#include #include #include using namespace std;typedef long long LL;LL n;int p; struct mat { int num[3][3];} E, ans;inline LL mu

2016-05-20 11:16:21 392

原创 【BZOJ3348】Cows【凸包】【凸包面积】

【题目链接】题意:求凸包,求面积,然后给面积除以50,向下取整。用的Andrew算法,即跑两次,先求出下凸包,然后再求出上凸包。求面积时候应该用凸包数组求,结果写成了原来的点的数组,调了20多分钟。弱智+2/* Telekinetic Forest Guard */#include #include #include #include using namespa

2016-05-20 07:39:54 561

原创 【BZOJ2229】[Zjoi2011]最小割【Gomory-Hu树】

【题目链接】可以参考《浅谈无向图最小割问题的一些算法及应用》王文涛然而并没有建树/* Telekinetic Forest Guard */#include #include #include using namespace std;const int maxn = 155, maxm = 30005, maxq = 10000, inf = 0x3f3f3f3f

2016-05-19 16:45:28 925

原创 【BZOJ3573】[Hnoi2014]米特运输【乱搞】

【题目链接】设atr[u]表示,从根节点到u节点,缩小了多少次,即一路上每个节点的儿子个数之积。设val[u]表示,atr[u] × u的权值。val相等的点,如果其中一个点不改变权值的话,那么其他的点都不用改变。那么我们取val的众数,用n减去众数的个数就是答案。由于atr和val太大了,所以要取log。/* Telekinetic Forest Guard

2016-05-19 11:04:28 313

原创 【BZOJ3571】[Hnoi2014]画框【最小乘积匹配】

【题目链接】类似最大乘积生成树那样做,只不过是把求生成树改成了求完美匹配。【chenyushuo的题解】/* Telekinetic Forest Guard */#include #include #include using namespace std;const int maxn = 75, inf = 0x3f3f3f3f;struct po { int

2016-05-19 08:52:37 606

原创 【BZOJ3996】[TJOI2015]线性代数【最小割】

【题目链接】大爷的题解【POPOQQQ的题解】/* Telekinetic Forest Guard */#include #include #include using namespace std;const int maxn = 300005, maxm = 1000005, inf = 0x3f3f3f3f;int n, head[maxn], cur[maxn

2016-05-18 16:22:04 495

原创 【BZOJ1007】[HNOI2008]水平可见直线【半平面交】

【题目链接】学习一发计算几何基础。/* Telekinetic Forest Guard */#include #include #include #include using namespace std;typedef double DB;const int maxn = 50005;const DB eps = 1e-6;struct _line { D

2016-05-18 15:32:44 366

原创 【BZOJ3862】Little Devil I【树链剖分】【线段树】

【题目链接】一棵树,每个边有黑白两种颜色,要支持三种操作1 一条链上的颜色取反2 只有一个顶点在一条链上的边的颜色取反3 查询一条链上黑色边的个数两个线段树,分别维护重链的颜色,轻链的颜色。重链的两个端点需要分别讨论。/* Telekinetic Forest Guard */#include #include #include using n

2016-05-17 16:06:51 736

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除