自定义博客皮肤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.

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

原创 【BZOJ1858】[Scoi2010]序列操作【线段树】

【题目链接】调了一早上,码力++。大概跪了几个地方:pushdown里rx1手滑打成了rx0。查询最大子段函数,区间合并忘了上传sum。mx1合并时候直接写了赋值,忘了和原来的值取max。/* Pigonometry */#include #include #include using namespace std;const int maxn

2016-04-30 14:13:18 695

原创 【BZOJ1449】[JSOI2009]球队收益【最小费用最大流】【单调增函数建图】

【题目链接】【POPOQQQ的题解】%一发建图姿势。/* Pigonometry */#include #include #include using namespace std;typedef long long LL;const int maxn = 10005, maxm = 500005, maxq = 100000, inf = 0x3f3f3f3f;i

2016-04-29 22:55:01 504

原创 【CodeChef-ANUDTQ】Dynamic Trees and Queries【Splay】【DFS序】

【题目链接】第一次见到用Splay维护DFS序的题。(其实一开始看jiry_2题解,写的LCT,结果TLE / RE。重新思考人生后换成了Splay)又忘把标记下传了。。/* Pigonometry */#include #include using namespace std;typedef long long LL;const int maxn

2016-04-29 18:27:46 568

原创 【Ural1041】Nikifor【拟阵】【线性无关】【高斯消元】【矩阵的秩】

【题目链接】这题有毒...论文 刘雨辰《对拟阵的初步研究》 里提到了这个题,于是来做一下。这题做法是贪心,把每个向量的花费从小到大排序,然后能放就放。主要是判断放入一个向量之后,是不是线性无关的。所以我们去求矩阵的秩,看是否增加了1。和一般的高斯消元不同,一般的是用当前行去消其他行,而这个是用其他行消当前行...为了方便,记录一个vis[j]数组,表示第j列(第j列非0

2016-04-29 12:01:44 914

原创 【BZOJ1093】[ZJOI2007]最大半连通子图【SCC】【DAG】【DP】

【题目链接】先SCC缩点,在DAG上跑最长路,顺便统计出到达每个点的最长路的路径个数。/* Pigonometry */#include #include #include #include #include using namespace std;typedef pair pii;const int maxn = 100005, maxm = 1000005, ma

2016-04-29 10:18:54 614

原创 【BZOJ3676】[Apio2014]回文串 【回文自动机】

【题目链接】学习一发回文自动机!照着hzwer的模板打了一发/* Pigonometry */#include #include #include using namespace std;typedef long long LL;const int maxn = 300005;char str[maxn];struct _pam { int son[maxn

2016-04-29 08:55:53 459

原创 【BZOJ3940】[Usaco2015 Feb]Censoring【AC自动机 / KMP】

【题目链接】【BZOJ3942题解】的加强版,但是没有什么区别。/* Pigonometry */#include #include #include using namespace std;const int maxn = 1000005, maxq = maxn;int n, pos[maxn], q[maxq];char s[maxn], str[maxn], a

2016-04-28 23:05:31 573

原创 【BZOJ3942】[Usaco2015 Feb]Censoring【AC自动机 / KMP】

【题目链接】记录一个当前串长为i时,在AC自动机上的哪个节点。找到匹配串时,直接O(1)跳到那个节点就行了。/* Pigonometry */#include #include #include using namespace std;const int maxn = 1000005, maxq = maxn;int n, pos[maxn], q[maxq];char

2016-04-28 23:03:48 669

原创 【BZOJ2772】policija【BCC】【割顶】【离线】【分治】【并查集】

【题目链接】先跑出dfs树。对于两个操作,先把不连通的情况用并查集搞掉。另外对于操作1,如果G1-G2是非树边,那么形成了环,这种情况肯定是yes。然后跑Tarjan,对每个操作形成的子树讨论一下就完了。#include /* Pigonometry */#include #include #include using namespace std;const

2016-04-28 15:33:20 567

原创 【BZOJ2773】ispiti【CDQ分治】【线段树】

【题目链接】很容易看出来是CDQ分治,但是细节比较多。令B为x轴,A为y轴...给x轴排序要按降序排,而且当插入与查询在同一个点时,要先查询再插入,这样就不用维护次小值了。光给操作离散化了,忘了给点离散化...导致大数据GG。/* Pigonometry */#include #include #include using namespace

2016-04-28 12:14:43 670

原创 【BZOJ2713】[Violet 2]愚蠢的副官【数位DP】【质因数分解】【枚举】【记忆化搜索】

【题目链接】同【BZOJ1183的题解】/* Pigonometry */#include #include #include using namespace std;typedef long long LL;int cnt[5];LL A, B, lb, ub, ans, dp[20][33][20][14][12], dec[20];int fact[]

2016-04-28 12:10:20 670

原创 【BZOJ1183】[Croatian2008]Umnozak【数位DP】【质因数分解】【枚举】【记忆化搜索】

【题目链接】参考官方题解写的【官方题解下载地址】/* Pigonometry */#include #include #include using namespace std;typedef long long LL;int cnt[5];LL A, B, lb, ub, ans, dp[20][33][20][14][12], dec[20];int

2016-04-28 12:08:02 1099

原创 【BZOJ4562】[Haoi2016]食物链【DP】【DAG】【拓扑排序】

【题目链接】傻逼题。/* Pigonometry */#include #include using namespace std;const int maxn = 100005, maxm = 200005, maxq = 200000;int n, m, head[maxn], cnt, in[maxn], out[maxn], dp[maxn], q[maxq]

2016-04-27 21:57:27 1174

原创 【BZOJ3670】[Noi2014]动物园【KMP】【fail树】

【题目链接】先求出fail数组,然后在fail树上做个前缀和,然后直接统计就行了。。/* Pigonometry */#include #include #include using namespace std;typedef long long LL;const int maxn = 1000005, p = 1000000007;int n, fail[max

2016-04-27 21:24:22 542

原创 【BZOJ2502】清理雪道【有上下界的最小流】

【题目链接】发现每条边最少走一次,最大走inf次,那么建图就出来了。从源点向每个点连边,容量为inf。原图中每条边的下界为1,上界为inf。每个点向汇点连边,容量为inf。跑有上下界的最小流就行了。最小流写法看了【POPOQQQ的题解】/* Pigonometry */#include #include using namespace std;con

2016-04-27 10:40:14 901

原创 【BZOJ3609】[Heoi2014]人人尽说江南好【博弈】【打表找规律】

【题目链接】没有子游戏,所以SG应该是用不上了。然后来愉快的写暴力吧。#include #include #include using namespace std;const int maxn = 1005;int n, m, num[maxn];inline bool check() { bool flag = 1; for(int i = 1; i 0

2016-04-27 09:08:53 1452

原创 【BZOJ3876】[Ahoi2014]支线剧情【最小费用最大流】

【题目链接】300题了orz。【POPOQQQ的题解】%%%神奇的建图。/* Pigonometry */#include #include #include using namespace std;const int maxn = 305, maxm = 10005, maxq = 10000, inf = 0x3f3f3f3f;int n, head[ma

2016-04-26 16:40:25 654

原创 【BZOJ1531】[POI2005]Bank notes【多重背包】

【题目链接】照着论文打了一发,发现还挺好玩。/* Pigonometry */#include #include #include using namespace std;const int maxn = 20005;int n, m, dp[maxn], w[maxn], c[maxn];inline int iread() { int f = 1, x = 0;

2016-04-26 15:47:50 702

原创 【BZOJ1564】[NOI2009]二叉查找树【区间DP】

【题目链接】这是一棵Treap,而且我们知道BST的中序遍历的数据值是递增的,那么我们按照数据值排个序,就得到中序遍历了。然后就变成区间DP啦。设dp[l][r][m]表示,区间[l, r]的节点组成的树中的,根节点的权值≥m的最小代价。然后枚举根节点转移。(1)将根节点i的权值修改为m,有dp[l][r][m] = dp[l][i - 1][m] + dp[i + 1][r][m

2016-04-26 15:21:18 954

原创 【BZOJ1565】[NOI2009]植物大战僵尸【最大权闭合图】【拓扑排序】

【题目链接】很容易看出是最大权闭合图,主要是处理环的情况。我们发现如果按照最大权闭合图那样建图,那么环上点不能取,而且指向的环上的点也不能取,这就麻烦了...所以我们拓扑序按照反向图找环就行了。/* Pigonometry */#include #include using namespace std;const int maxn = 1005, maxm = 5000

2016-04-26 11:45:05 482

原创 【BZOJ1305】[CQOI2009]dance跳舞【最大流】【二分】

【题目链接】看了【POPOQQQ的题解】,建图比较厉害。写网络流第一次把点开小了...orz/* Pigonometry */#include #include #include using namespace std;const int maxn = 255, maxm = 10005, maxg = 55, maxq = 10000, inf = 0x3f3f

2016-04-25 22:24:39 813

原创 【BZOJ1441】Min【裴蜀定理】

【题目链接】a1x1 + a2x2 + ... + anxn = s有解,当且仅当gcd(a1, a2, ..., an) | s。所以s的最小值就是gcd。/* Pigonometry */#include #include using namespace std;int n, ans;inline int iread() { int f = 1, x =

2016-04-25 17:57:18 407

原创 【BZOJ1412】[ZJOI2009]狼和羊的故事【最小割】

【题目链接】显然是最小割...随便抽了个题怎么又是网络流.../* Pigonometry */#include #include using namespace std;const int maxn = 10005, maxm = 100005, maxq = 50000, inf = 0x7fffffff;int n, m, head[maxn], cur[ma

2016-04-25 17:26:34 566

原创 【BZOJ1324】Exca王者之剑【最小割】

【题目链接】论文题,见 胡伯涛《最小割模型在信息学竞赛中的应用》WA了几发,最后发现是dinic模板写错了= =,看来今天不适合做题。/* Pigonometry */#include #include using namespace std;const int maxn = 10005, maxm = 100005, maxq = 50000, inf = 0x7

2016-04-25 17:14:56 509

原创 【BZOJ1283】序列【最大费用最大流】

【题目链接】做了才发现是论文题,但是和论文上建图不一样。。杨沐《浅析信息学中的“分”与“合”》看的【POPOQQQ的题解】大爷的题解orz。队列似乎开小了,TLE了一次。/* Pigonometry */#include #include #include using namespace std;const int maxn = 1005, maxm

2016-04-25 14:52:02 586

原创 【BZOJ1194】[HNOI2006]潘多拉的盒子【BFS】【SCC】【拓扑排序】【DAG最长路】【自动机】

【题目链接】这题有毒orz。判断两个自动机是否有升级关系,BFS一次就行了orz。两个自动机都从0开始,同时走0,同时走1。如果一个自动机到达输出点,而另一个没到达,那么没有升级关系。然后根据升级关系建图,Tarjan缩点,然后跑DAG上最长路就行了。注意一个强联通内都是互相有升级关系的,跑最长路时要取size而不是取1,WA了一发.../* Pigonomet

2016-04-23 17:15:33 871

原创 【BZOJ1260】[CQOI2007]涂色paint 【区间DP】

【题目链接】设dp[i][j]表示[i, j]这段字符串经过粉刷的最小次数。分两种情况转移:(1)str[i] == str[j]那么str[i]有可能在粉刷str[j]的时候被粉刷了,此时dp[i][j] = dp[i + 1][j];对str[j]也同理,有dp[i][j] = dp[i][j - 1]。(2)str[i] != str[j]那么枚举中间位置k,

2016-04-23 15:34:26 449

原创 【BZOJ1264】[AHOI2006]基因匹配Match【DP】【LCS】【树状数组】

【题目链接】相对于一般的LCS来说,这个问题可以直接得到某个字符在字符串内的位置。先把第一个串读入,处理出每个字符出现的位置。然后枚举第二个串,对于当前的字符,直接枚举这个字符在第一个串里出现的位置,然后转移。转移需要用到前缀最大值,用树状数组来维护。orz神题。/* Pigonometry */#include #include #include u

2016-04-23 11:51:08 436

原创 【BZOJ1271】[BeiJingWc2008]秦腾与教学评估【二分】【神题】

【题目链接】神题!利用奇数只有一个的性质,二分位置,算前缀和,如果前缀和是奇数,那么答案一定在前面,否则有可能在右边。注意二分时候有可能超int,要开LL。/* Pigonometry */#include #include #include using namespace std;typedef long long LL;const int maxn =

2016-04-23 10:50:48 567

原创 【BZOJ3622】已经没有什么好害怕的了【计数DP】【姿势】

【题目链接】【dyllalala的题解】说下我个人的理解...先把两个数组排序,设next[i]表示满足第i个糖果>第j个药片的最大的j。显然这个next是单调的,可以O(n)求出。设dp[i][j]表示前i个糖果里,至少有j组糖果>药片(即这j组以外的其他情况都不考虑)的方案数。考虑第i个糖果,有两种转移:(1)不管,dp[i][j] = dp[i - 1][j]

2016-04-23 08:39:11 385

原创 【BZOJ3620】似乎在梦中见过的样子【KMP】【暴力】

【题目链接】枚举左端点,然后跑KMP,统计一下就好了= =。/* Pigonometry */#include #include #include using namespace std;const int maxn = 15005;int len, k, fail[maxn];char str[maxn];inline void getfail(int pos

2016-04-22 22:08:59 519

原创 【BZOJ1133】[POI2009]Kon【DP】

【题目链接】设dp[i][k],表示前i个站台,在第i到第i+1个站台之间查票,一共查了k次票的最大人数。那么有dp[i][k] = max{dp[j][k - 1] + w},0 其中w = ∑A[x][y],j 把w在二维平面里画出来,刚好是A的后缀和。然后就可以转移了。行末换行的写法是学习的PoPoQQQ的(%%%)/* Pigonometry *

2016-04-22 17:09:14 491

原创 【BZOJ1112】[POI2008]砖块Klo【Splay】

【题目链接】最终高度一定是中位数,然后Splay维护一下就可以了。答案会炸int。一开始只给加法加了LL,最后意识到先算的是乘法,所以给乘法加了LL就AC了。/* Pigonometry */#include #include #include using namespace std;typedef long long LL;const int m

2016-04-22 15:39:18 422

原创 【BZOJ4546】codechef XRQRS【可持久化Trie / +主席树】

【题目链接】早上刚在CC上做了,中午就被人搬到BZOJ了。。不知道为什么n开50wRE,开了52w卡了下内存就过了。【CC上这题题解】/* Pigonometry */#include #include #include using namespace std;const int maxn = 520005, maxk = 21, maxnode = maxn

2016-04-22 14:57:18 1059

原创 【CodeChef-XRQRS】Xor Queries【可持久化Trie / +主席树】

【题目链接】有中文题面就不发题意了。似乎维护一个可持久化Trie和一个主席树就可以做了,但是仔细想想好像只需要一个可持久化Trie就完了。脑补了一下Trie上找第k大和统计数个数,似乎是对了。1A了。。/* Pigonometry */#include #include #include using namespace std;const int ma

2016-04-22 08:27:24 981

原创 【BZOJ1266】[AHOI2006]上学路线route【最短路图】【最小割】

【题目链接】在最短路图上跑最小割。用dijkstra写WA了十几发,不知道什么问题,换成Floyd就过了。/* Pigonometry */#include #include #include using namespace std;const int maxn = 505, maxm = maxn * maxn, inf = 0x3f3f3f3f, ma

2016-04-21 21:56:05 517

原创 【BZOJ1189】[HNOI2007]紧急疏散evacuate【最大流】【二分】

【题目链接】先处理出每个人到每个门的最短距离。二分答案mid。从S到每个人连边,容量为1。每个门拆为mid个点,第i个点代表第i个时刻的门,每个人向 第(最短距离)个点 ~ 第mid个点 连边。每个门向T连边。跑最大流,看是否满流。一直担心建图错,结果没错,倒是忘了判impossible了。/* Pigonometry */#include

2016-04-21 16:22:59 1057

原创 【BZOJ1131】[POI2008]Sta【TreeDP】

【题目链接】经典TreeDP。/* Pigonometry */#include #include #include using namespace std;typedef long long LL;const int maxn = 1000005;int n, head[maxn], cnt, ans, size[maxn];LL sum;struct

2016-04-21 14:02:29 368

原创 【BZOJ1123】[POI2008]BLO【割顶】

【题目链接】题意可见discuss。用Tarjan求割顶,然后对割顶的所有子树求点对个数(前缀和扫一遍),最后把自身和其他点的答案加上。没注意边,数组开小了。/* Pigonometry */#include #include using namespace std;typedef long long LL;const int maxn = 1000

2016-04-21 11:39:37 670

原创 【BZOJ1103】[POI2007]大都市meg【树链剖分】【线段树】【或 树状数组 + dfs序】

【题目链接】想都没想直接树剖去了...看了题解发现树状数组维护dfs序也可以做。树剖:/* Pigonometry */#include #include #include using namespace std;const int maxn = 250005;int n, head[maxn], cnt;struct _edge { int

2016-04-21 08:38:58 908

空空如也

空空如也

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

TA关注的人

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