自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

poursoul

仔细读题!不要偷懒!多看Clarification!

  • 博客(718)
  • 资源 (1)
  • 收藏
  • 关注

原创 【牛客网】2017年浙江工业大学大学生程序设计迎新赛热身赛 F题 方块 I【证明题】【想法题】

【牛客网】2017年浙江工业大学大学生程序设计迎新赛热身赛 F题 方块 I时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K,其他语言262144K 64bit IO Format: %lld 题目描述 有 N 个方块排成一排,每个方块都染有颜色,第 i 个的颜色为 Ci,一共有三种颜色,分别为红,黄,蓝,现在你可以对相邻的颜色不同的方块进行施法,使其变成第三

2017-12-10 11:02:02 1621 3

原创 【codeforces】741E. Arpa’s abnormal DNA and Mehrdad’s deep interest【后缀数组+分块】

题目链接:【codeforces】741E. Arpa’s abnormal DNA and Mehrdad’s deep interest观察两个插入位置对他们rank的影响,可以发现,可以拆成求5段lcp,因此我们在将两个串拼接后求一个后缀数组,然后就可以直接对所有插入位置求出他们的rank了。然后询问可以根据k分块,这题就做完了。 就是需要写一会儿。#include <bits/stdc++

2016-12-09 14:36:42 1691

原创 【codeforces】678 F. Lena and Queries【线段树维护凸壳】

题目链接:【codeforces】678 F. Lena and Queries#include <bits/stdc++.h>using namespace std ;typedef long long LL ;typedef pair < int , int > pii ;#define getid( l , r ) l + r | ( l != r )const int MAXN = 30

2016-12-06 19:57:42 1486

原创 【UVALive】7502 Suffixes and Palindromes【根据sa数组以及回文半径数组构造字典序最小的串】

题目链接:【UVALive】7502 Suffixes and Palindromes根据回文半径数组能得出一堆不等相等关系,相等缩点,不等建边。 根据sa数组的对偶数组rank数组的性质,考虑sa[i]和sa[i-1],如果如果rank[sa[i]+1]>rank[sa[i-1]+1]则s[sa[i]]可以等于s[sa[i-1]];如果rank[sa[i]+1]>rank[sa[i-1]+1]则

2016-12-06 12:13:30 1026

原创 【HDU】5994 Generator and Monitor【KD树】

题目链接:【HDU】5994 Generator and Monitor看懂题就会做系列,模板题。#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 200005 ;const int

2016-12-02 19:25:26 1279

原创 【topcoder】570div1 900 CurvyonRails【费用流】

#include <bits/stdc++.h>using namespace std ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 3505 ;const int MAXE = 100005 ;const int INF = 0x3f3f3f3f ;struct Edge { int v , c ,

2016-11-30 21:09:02 564

原创 【codeforces】739D. Recover a functional graph【最大流实现匹配】

题目链接:【codeforces】739D. Recover a functional graph其实就是一个匹配问题,先枚举最大的那些”x ?”放在哪个环上,那么接下来哪些地方是一定要填的都已经知道了,还没有填的地方我们就用匹配来实现。构造方案比较简单,肯定是链只从同样大小的环中随便选一个,然后再选一个点连出来,然后确定最长的树链,剩下的深度为ii的就指向深度为i−1i-1的树链上的点即可,深度0

2016-11-29 16:11:28 911 1

原创 【hrbust】2298 Diamond 【数学+暴力】

题目链接: 【hrbust】2298 Diamond枚举斜率算贡献。n2lognn^2\log n预处理,O(1)O(1)查询。PS:一开始写了n2lognn^2\log n每组,然后TLETLE了,思考了一下发现可以先预处理,然后每组O(N)O(N),结果又TLETLE了……然后再思考了一下发现可以O(1)O(1)询问,就是代码量瞬间长了一些……总体来说还是比较简单的……#include <bit

2016-11-28 16:02:16 426

原创 【topcoder】SRM696 div1 550 Clicounting【折半枚举求最大团+高维前缀最大值】

题目链接:【topcoder】SRM696 div1 550 Clicounting最大团可以n2nn2^n搞,然后对这个可以做高维前缀最大值。就可以得到以某个状态的子集构成的最大团的大小。然后显而易见可以折半爆搜,然后瞎几把搞就好了。#include <bits/stdc++.h>using namespace std ;#define clr( a , x ) memset ( a , x ,

2016-11-07 22:27:37 825

原创 【玲珑杯】1048 - Best substring【manacher+分治维护凸壳】

题目链接:【玲珑杯】1048 - Best substringwa了一辈子,最后发现是利用归并排序后的退栈策略错了。应该是判栈顶和当前元素的关系,然而我偷懒只判了相邻两个元素的关系,gg。#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , s

2016-11-07 14:52:02 449

原创 【codeforces】660F. Bear and Bowling 4【分治+维护凸壳】

题目链接:【codeforces】660F. Bear and Bowling 4考虑对序列分治,然后可以发现,以左半部分每个下标为x,右边则可以表示成kx+bkx+b的形式,因此可以对右边的直线维护一个下凸壳。 复杂度O(nlog2n)O(nlog^2n),如果用归并排序代替快排,可以做到O(nlogn)O(nlogn)#include <stdio.h>#include <string.h>

2016-11-06 21:56:37 902

原创 【PA】PA2014Final Wykładzina【单调栈+双指针+均摊分析】

题目链接:【PA】PA2014Final Wykładzina均摊分析可知复杂度O(N2)O(N^2)#include <bits/stdc++.h>using namespace std ;typedef long long LL ;typedef pair < int , int > pii ;typedef unsigned long long ULL ;#define clr( a ,

2016-11-06 19:37:40 507

原创 【codeforces】730F. Ber Patio【dp】

题目链接:【codeforces】730F. Ber Patiodp[i][j]dp[i][j]表示买了前ii件物品,另外得到了jj个代币所用的最小现金数。买第i+1i+1件前还剩多少代币可用总代币-买了前ii件另外获得的代币(即dp[i][j]dp[i][j]的jj)-买前ii件要花多少钱(即∑ik=1ak\sum_{k=1}^{i}a_k)+买前ii件用了多少现金(即dp[i][j]dp[i][

2016-11-05 11:34:42 584

原创 【51nod】1302 矩形面积交【优先队列贪心】

题目链接:【51nod】1302 矩形面积交因为最后可以旋转,所以每一组的矩形一定是短边对短边,长边对长边。 考虑短边最短的一定在AA组,然后我们将其余的矩形按照长边排序,枚举在BB组的最短长边,逐个将矩形插入优先队列,然后优先队列中个数大于NN时,取出短边最短的加入AA,然后同时维护两组矩形的面积即可。 因为此时相当于固定了AA组的短边(最小只可能是一开始孤立出来的矩形),AA组的长边以及BB

2016-11-05 10:24:35 943

原创 【opencup】XVI Open Cup named after E.V. Pankratiev. GP of SPB K.Captain Tarjan【树形dp】

题目大意:给一棵NN个节点的树,你可以选择任意一个点作为根然后树链剖分(树链剖分的定义:如果这个点不是叶子,则其中恰好一条边为重边,其余均为轻边),剖分的方式由你定。然后接下来有MM对(u,v)(u,v),定义(u,v)(u,v)为树上节点uu到节点vv的最短路径。现在你要确定一个剖分方案,使得所有对(u,v)(u,v)经过的轻边个数之和最小,经过多次算多次。输出个数之和。N,M∈[1,1e5]N,

2016-11-04 18:58:34 958

原创 【BZOJ】3992 [SDOI2015]序列统计 【离散对数下的NTT】

题目链接:【BZOJ】3992 [SDOI2015]序列统计 利用原根的性质,对下标做变换,使得乘法变成加法,然后就有卷积性质了。n很大我们就在外面套一层快速幂即可。#include <bits/stdc++.h>using namespace std ;typedef long long LL ;typedef pair < int , int > pii ;typedef unsigne

2016-11-03 11:06:33 551

原创 【codeforces】gym 101137 E - Economy Printing【dp】

题目链接:【codeforces】gym 101137 E - Economy Printing对值排序,会发现只有最后两个元素有用,枚举他们是被压缩在哪种类型,接在哪个数后面,dp即可。#include <bits/stdc++.h>using namespace std ;typedef pair < int , int > pii ;#define clr( a , x ) memset (

2016-11-02 20:42:56 729

原创 【codeforces】gym 101137 K - Knights of the Old Republic【用最小生成树对图做集合dp】

题目链接:K - Knights of the Old Republic考虑对图集合dp,一个连通块的dp值为两个连通块的值的和或者强制加一条新边后的最小值,取个最小值(边从小到大枚举,则强制加一条最大的边会导致连通块内较小的边一定都选,则会构成一个生成树)。用kruskal实现这个dp过程即可。#include <bits/stdc++.h>using namespace std ;typede

2016-11-02 20:40:21 698

原创 【HDU】5958 New Signal Decomposition【离散对数下的FFT】

题目链接:【HDU】5958 New Signal Decomposition在此先感谢小q对我的指导,没有q老师的帮助,估计永远也做不出来了。首先我们考虑对这个式子做离散对数。令gg为pp的某个原根,则有: bi=∑p−1j=0aj⋅r(i,j)\quad b_i=\sum_{j=0}^{p-1}a_j\cdot r(i,j) bi=∑p−1j=0aj⋅2sin32πi⋅jp\quad b_i

2016-11-01 21:57:42 1238 1

原创 【HDU】5436 Transmigration tree【树链剖分+dp+rmq】

题目链接:【HDU】5436 Transmigration tree#pragma comment(linker, "/STACK:16777216")#include <stdio.h>#include <string.h>#include <vector>#include <algorithm>using namespace std ;typedef long long LL ;#de

2016-11-01 11:30:19 622

原创 【HDU】5420 Victor and Proposition【SCC+线段树】

题目链接:【HDU】5420 Victor and Proposition#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 100005 ;const int MAXM = 40000

2016-11-01 11:25:54 468

原创 【HDU】5426 Rikka with Game【DP】

题目链接:【HDU】5426 Rikka with Game#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 100005 ;const int MAXE = 200005 ;con

2016-11-01 11:22:42 854

原创 【HDU】5574 Colorful Tree【子树染色,询问子树颜色数——线段树+bit+lca+set】

题目链接:【HDU】5574 Colorful Tree#include <bits/stdc++.h>using namespace std ;typedef long long LL ;typedef pair < int , int > pii ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 100005

2016-11-01 11:19:28 2420

原创 【HDU】5571 tree【动态点分治】

题目链接:tree#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 30005 ;const int MAXE = 60005 ;struct Edge { int v , c

2016-11-01 11:14:31 1032

原创 【HDU】5566 Clarke and room【树链剖分+AC自动机】

题目链接:Clarke and room#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define ls ( o << 1 )#define lson ls , l , m#define rs ( o << 1 | 1 )#define rson rs , m + 1 , r#define rt 1

2016-11-01 11:09:39 781

原创 环上k划分的和的gcd的最大值【gcd基本性质的利用】

今早看到的题,想了下会做了,但是觉得这题挺有意思的,于是打算写一下做法。本题利用了gcd的基本性质:更相减损法以及结合律,平时做gcd的题基本没用到过这两性质,而本题对这性质进行了充分利用。思路: 首先我们考虑给一个序列,我们该怎么做。 令f[i]=a[1]+a[2]+…+a[i]。 我们考虑序列的一个k+1划分f[x1],f[x2]-f[x1],f[x3]-f[x2],…,f[n]-f[xk

2016-10-31 20:59:17 1672

原创 【codeforces】gym 101138 K. The World of Trains【前缀和优化dp】

题目链接:K. The World of Trains记录一个横着的前缀dp和以及斜着的前缀dp,复杂度O(n2)O(n^2)#include <bits/stdc++.h>using namespace std ;typedef pair < int , int > pii ;typedef long long LL ;#define clr( a , x ) memset ( a , x ,

2016-10-31 19:09:52 947

原创 【Tsinsen】1228 飞飞侠【并查集优化最短路】

题目链接:A1228. 飞飞侠#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 155 ;const LL INF = 1e18 ;struct Node { LL dis ;

2016-10-31 19:04:11 825

原创 【POJ】2449 Remmarguts' Date【k短路】

题目链接:Remmarguts’ Datek短路模板题,用这题验证了我可持久化左偏树的正确性。#include <stdio.h>#include <vector>#include <queue>#include <algorithm>using namespace std ;typedef long long LL ;typedef pair < int , int > pii ;ty

2016-10-31 15:59:36 865

原创 【HDU】5960 Subsequence 【可持久化左偏树维护K短路】

题目链接:Subsequence吐槽,先是对着定义yy了可持久化二项堆,然后发现不好搞这个k短路,然后找了左偏树的定义,对着yy了20分钟写出了可持久化左偏树,然后过了poj2449后就1A了这个题。#include <stdio.h>#include <vector>#include <queue>#include <algorithm>using namespace std ;typed

2016-10-31 15:56:36 2704

原创 可持久化二项堆

namespace Binomial_Heap { struct Node { int c[2] , x ; LL val ; } T[MAXN * 200] ; struct Heap { int n ; pii rt[BLOCK] ; Heap () : n ( 0 ) {}

2016-10-31 13:55:27 713

原创 【HDU】5957 Query on a graph【分类讨论+bfs序线段树】

题目链接:Query on a graph水题#include <bits/stdc++.h>using namespace std ;typedef long long LL ;typedef pair < int , int > pii ;typedef unsigned long long ULL ;#define clr( a , x ) memset ( a , x , sizeof

2016-10-30 17:53:25 1262

原创 【UVALive】6776 2014WorldFinal G Metal Processing Plant【2-sat——bitset优化kosaraju求scc】

题目链接:Metal Processing Plantbitset优化kosaraju,复杂度O(n^2/64),总复杂度O(n^4/64)。#include <bits/stdc++.h>using namespace std ;typedef long long LL ;typedef pair < int , int > pii ;typedef unsigned long long U

2016-10-27 19:05:02 771

原创 【BZOJ】4643 卡常大水题【bitset优化bfs】

题目链接:卡常大水题#include <bits/stdc++.h>using namespace std ;typedef long long LL ;typedef pair < int , int > pii ;typedef unsigned int UI ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN =

2016-10-26 17:41:33 1082

原创 【HDU】5899 oasis in desert 【二分匹配】

题目链接:oasis in desert#include <bits/stdc++.h>using namespace std ;typedef long long LL ;typedef pair < int , int > pii ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 505 ;const int

2016-10-24 20:45:00 573

原创 【HDU】5905 Black White Tree【树dp,枚举子树,对于一个a,其对应的可行b一定是一个连续区间】

题目链接:Black White Tree枚举子树,对于一个a,其对应的可行b一定是一个连续区间。#include <bits/stdc++.h>using namespace std ;typedef long long LL ;typedef pair < int , int > pii ;#define clr( a , x ) memset ( a , x , sizeof a )con

2016-10-24 19:36:17 664

原创 【HDU】5549 Walk Around The Campsite【极角排序+set+最短路dp】

题目链接:Walk Around The Campsite要知道多边形的边只会在端点相交。则如果以一个点为原点,作射线,然后旋转,那么遇到边的左端点我们往set插入线段,遇到边的右端点我们删除线段,那么任意时刻在set中的线段和射线的交点到原点的距离的大小关系是相对不变的。那么我们就可以通过动态维护set的操作符’<’动态维护线段距离原点的远近了。 接下来就很简单了,枚举原点,然后极角排序,然后转

2016-10-23 22:23:12 1481

原创 【UOJ】176 新年的繁荣【多路增广生成树】

题目链接: 新年的繁荣#include <bits/stdc++.h>using namespace std ;typedef pair < int , int > pii ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 100005 ;struct Seg {

2016-10-17 19:14:15 1039

原创 【HDU】5817 Ice Walls【极角排序+树状数组+最短路】

题目链接:Ice Walls#include <bits/stdc++.h>using namespace std ;typedef long long LL ;typedef pair < double , int > pii ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 1005 ;const doubl

2016-10-17 17:10:33 503

原创 【51nod】1291 Farmer 【求n*m的矩形内全1的i*j的矩形个数】【dp】

题目链接:【51nod】1291 Farmer去年做的题,一直没有放出来,单调栈,O(N^2)。O(N^2logN)也能过。#include <bits/stdc++.h>using namespace std ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 1005 ;char s[MAXN] ;int U[M

2016-10-13 14:52:09 1474

并查集分类1

大家尽管下载,并查集专题现在已经上传,尽请期待

2014-03-14

空空如也

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

TA关注的人

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