自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

嗯。

嗯。

  • 博客(472)
  • 资源 (2)
  • 收藏
  • 关注

原创 POJ 3276 Face The Right Way 模拟

有一排牛方向是向前或者向后,每次可以把连续的k头牛转换方向,求最少的次数m使得所有牛都向前以及k,枚举k, 然后判断是否可行,从左往右,维护一个区间和即可。#include #include #include #include #include using namespace std;int a[5010], b[5010];int main(){ i

2016-07-15 09:40:48 282

原创 POJ 3253 Fence Repair 贪心

有一块木块,要切n-1刀,最终变成n块,告诉你最终每一块的长度,每次切的时候需要加上当前切的那一块的长度,求一种切割方案使得和最小。这题需要逆推,最后一刀肯定是长度最小的2块,答案加上这两块的长度,然后回退,把这两块看成一块,得到n-1块,一直这样下去直到最终只有1块为止。#include #include #include using namespace std;typede

2016-07-15 09:40:43 305

原创 2015 ACM/ICPC Asia Regional Shanghai Online

题目在这里上海赛区网络赛5468 Puzzled Elena5469 Antonidas5470 Typewriter5471 Count the Grid5472 Code Formatting5473 There was a kingdom5474 A simple graph problem5475 An easy problem用线段树维

2016-07-15 09:34:03 399

原创 2015 ACM/ICPC Asia Regional Shanghai Online

题目在这里上海赛区网络赛5468 Puzzled Elena5469 Antonidas5470 Typewriter5471 Count the Grid5472 Code Formatting5473 There was a kingdom5474 A simple graph problem5475 An easy problem用线段树维

2016-07-14 09:34:18 619

原创 2015 ACM/ICPC Asia Regional Shenyang Online

题目在这里Shenyang Online1001 Traversal1002 Best Solver1003 Minimum Cut1004 Dividing This Product1005 Excited Database1006 Fang Fang简单题1007 Matches Puzzle Game1008 Hold Your Hand

2016-07-14 09:34:12 330

原创 2015 ACM/ICPC Asia Regional Changchun Online

弱菜目前只做了9个,5个签到题。题目链接Changchun Online1001 Alisha’s Party简单题,优先队列搞搞就行了。1002 Ponds简单题1003 Aggregated Counting感觉有点绕的题目,把连续出现相同次数的数字看成一段,最多50w段,然后预处理一下前缀和。1004 Clock Adjusting待补

2016-07-14 09:34:11 425

原创 HDU 5442 Favorite Donut 最大表示法+KMP

首先2次最大表示法求出顺序和逆序情况下的位置,不过逆序求出来的是最大的下标,可以利用循环节来推出最小的位置。#include #include #include using namespace std;const int maxn = 1000010;int f[maxn];char s[maxn];void getFail(char p[]){ int m

2016-07-13 09:34:26 329

原创 HDU 5446 Unknown Treasure Lucas定理+中国剩余定理

数学本来就弱,现在大半年不练,果断简单题都不会了。。。先用lucas求出x mod 每一个素数结果,然后再用中国剩余定理解出x,不过要自己写乘法,防溢出。。。#include #include using namespace std;typedef __int64 LL;LL a[12], mm[12];LL mul(LL a, LL b, LL c){ LL

2016-07-13 09:34:25 309

原创 POJ 2486 Apple Tree 树形DP

有一颗苹果树,每个节点上面有很多苹果,从一个节点到另外一个可以到达的节点花费1步,求k步最多能吃到多少苹果。dp[root][j][0]为以root为根的子树走j步路在回到root最多获得多少苹果,dp[root][j][0]为以root为根的子树走j步路不回到root最多获得多少苹果。dp[root][j][0] = max(dp[root][j][0], dp[root][j-l][0

2016-07-13 09:34:21 246

原创 POJ 1904 King's Quest 强连通分量+二分匹配

好题啊,先赞一个,这里有个讲的好的,感觉让我讲也没他这么好。。。King's Quest#include #include #include #include #include using namespace std;const int maxn = 2010;vector G[maxn*2];vector G2[maxn*2];int pre[ma

2016-07-13 09:34:21 411

原创 HDU 3026 Chinese Chess 二分匹配(TLE...)

求有多少个点,满足不选这个点最大匹配减少,超时了,挖个坑, 以后实力够了在来填坑。。。#include #include #include using namespace std;const int maxn = 10010;const int maxm = 10010;bool vis[maxn];int y[maxn];int n, m;vector G

2016-07-13 09:34:20 393

原创 网络流模板 Dinic+ISAP

dinic递归版,堆栈溢出可以手动扩栈,改成非递归版本,或者改用效率更高的ISAP。struct Edge{ int from, to, cap, flow; Edge(){} Edge(int from, int to, int cap, int flow) : from(from), to(to), cap(cap), flow(flow){}};int n, m,

2016-07-13 09:34:16 489

原创 BZOJ 1208 宠物收养所 Splay树

Splay的简单应用,找和一个数最接近的数,例如找和x最接近的数,把x旋转到根,要么是左子树的最大值,要么是右子树的最小值。 #include #include #include #include using namespace std;typedef long long LL;const int mod = 1000000;const int maxn = 8

2016-07-12 09:32:50 323

原创 HDU 3436 Queue-jumpers Splay+离散化

有n个人从小到大排成一列,分别记为1,2...,m次询问,3种操作:1.把x这个人放到队首。2.求x这个人在哪个位置。3.求x这个位置是那个人。虽然最多有1亿个人,但是操作最多只有10w次,那就离散化,把连续一段没有出现过的数压缩成一个点,然后就是普通的Splay树了。#include #include #include using namespace std;

2016-07-12 09:32:50 297

原创 Splay树模版

#include #include #include #include using namespace std;typedef long long LL;const int maxn = 1000010;int pre[maxn], ch[maxn][2], sz[maxn];int root, top1; int val[maxn]; voi

2016-07-12 09:32:43 275

原创 HDU 3466 Proud Merchants 需要排序的背包

和普通的01背包不一样,多了一个限制,只有在剩余钱大于等于q的时候才能选。需要确定先后顺序,假设有A, B2个物品并且他们都会选择,如果先选A再选B那么选第二个的时候花费至少是q1+p2,如果先选B再选A,选第二个的时候花费至少是q2+p1,所以应该排个序,满足q1+p2 < q2+p1,移项得到q1-p1 < q2-p2。 #include #include #include

2016-07-11 09:35:55 361

原创 HDU 3473 Minimum Sum 划分树

有n个数,每次给出一段区间l,r,选出一个数X使得|X-Xi|(l<=i<=r)尽量小,X显然是中位数。此外还要得到区间和,这个可以在划分树递归的时候累加,当递归左子树的时候,可以加上所有大于中位数的数,递归右子树的时候可以减去所有小于中位数的数。 #include #include #include using namespace std;typedef __int64

2016-07-11 09:35:54 254

原创 HDU 3474 Necklace 单调队列

一串项链由C和J组成,可以从某一个位置切断,从左或者往右收集,问有多少种合法的切割方案,满足任意时刻C的数量不小于J的数量。单调队列维护最小值。 #include #include #include #include using namespace std;const int maxn = 2000010;char s[maxn];int q[maxn],

2016-07-11 09:35:54 374

原创 HDU 4348 To the moon 主席树成段更新

对于成段更新,以前都是访问到懒惰标记的节点然后向下更新,这次学了一个新的方法,遇到懒惰节点不向下更新,而是从根节点开始累加所有的标记值。 #include #include #include using namespace std;typedef __int64 LL;const int maxn = 200010;int ls[maxn*20], rs[maxn*

2016-07-11 09:35:54 333

原创 HDU 4251 The Famous ICPC Team Again 划分树 区间第K大

给n个数,m次询问,每次询问一个区间,输出该区间中间大的值,中位数?划分树模版题。 #include #include #include using namespace std;const int maxn = 100010;int tree[20][maxn], toleft[20][maxn], a[maxn];void build(int l, int r,

2016-07-11 09:35:53 256

原创 划分树模版

#include #include #include using namespace std;const int maxn = 100010;int tree[20][maxn], toleft[20][maxn], a[maxn];void build(int l, int r, int dep){ if(l == r) return;

2016-07-11 09:35:53 322

原创 SPOJ 3267. D-query 主席树

询问一段区间有多少个不同的数,用一个map维护数的位置,然后就是主席树基本应用。 #include #include #include #include using namespace std;const int maxn = 30010;int ls[maxn*20], rs[maxn*20], sum[maxn*20];int T[maxn], tot;

2016-07-08 10:00:49 469

原创 POJ 2154 Color Polya计数法+欧拉函数

学过Polya计数法的知道答案为∑n^gcd(i, n),但是n太大了,设gcd(i,n)的值为x,x显然是n的约数,所以可以从1到sqrt(n)枚举x,设i=y*x,i必须要有x这个因子,才能满足gcd(i, n)=x,并且gcd(i/x,n/x) == 1,所以满足的个数为n/x的欧拉函数值。#include #include #include #include #incl

2016-07-08 09:58:22 366

原创 ZOJ 2112 Dynamic Rankings 树状数组套主席树 动态第K大

动态求区间第K大,有修改操作,用树状数组求和,此外在ZOJ可能会超内存,参考了kuangbin巨巨,建树和修改分开来操作,建树用静态前缀和,修改用树状数组,每次求和2部分相加。#include #include #include using namespace std;const int maxn = 60010;const int maxm = 2500010;int

2016-07-08 09:58:08 515

原创 主席树模版

主席树模版 #include #include #include using namespace std;const int maxn = 100010;int ls[maxn*20], rs[maxn*20], sum[maxn*20];int T[maxn], tot;void build(int l, int r, int& rt){ rt =

2016-07-08 09:55:26 384

原创 Codeforces 557E Ann and Half-Palindrome DP+字典树

求字典序第K大的半回文串,半回文串满足第一位和最后一位相等,第三位和倒数第三位相等。。。。先用dp求出所有的半回文串,然后插入到字典树中统计个数,根据个数求第K大。#include #include char s[5010];int k;int dp[5010][5010];int ch[5010*5010/2][2];int sum[5010*5010/2];

2016-07-07 18:35:35 352

原创 字典树模版

静态版本 #include #include using namespace std;int ch[maxnode][sigma_size];int val[maxnode];int sz;void init(){ sz = 1; memset(ch[0], 0, sizeof(ch[0]));}int idx(char c){ retu

2016-07-07 18:35:35 236

原创 最近公共祖先模版

离线算法#include #include using namespace std;typedef long long LL;const int maxn = 12;int first[maxn], cnt;int anc[maxn][maxn], n;LL a[maxn];struct edge{ int u, v, next;}e[maxn

2016-07-07 18:35:31 310

原创 2015年省赛组队选拔赛1

http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=3617

2015-05-09 12:38:31 821

原创 2015年省赛个人热身赛3

http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=3182http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=3816

2015-05-09 12:37:24 817

原创 2014年5月TOJ月赛

http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=4019

2015-05-09 12:14:25 761

原创 2014年4月TOJ月赛

http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=4588

2015-05-09 11:25:17 689

原创 2014年省赛组队练习赛8

http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=4631不会

2015-05-09 10:58:04 846

原创 2014年省赛选拔组队系列赛4

http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=4495http://blog.csdn.net/nike0good/article/details/9213121

2015-05-08 22:05:38 870

原创 2014年省赛选拔组队系列赛2

http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=4453不会http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=4454理论AChttp://acm.tzc.edu.cn/acmhome/problemdet

2015-05-08 21:21:23 726

原创 2014年省赛组队练习赛4

http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=3870http://www.cnblogs.com/rausen/p/4067694.html

2015-05-08 20:01:32 902

原创 2014年省赛组队练习赛2

http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=3869http://www.fx114.net/qa-172-294129.aspx

2015-05-08 19:10:20 708

原创 福州大学第十二届程序设计竞赛

AK

2015-05-08 17:41:24 1012

转载 Fibonacci数列通项公式推导

前段时间很多人问道Fibonacci数列的通向公式是怎样推导出来的,下面给出一个朴素的初等方法。方法说穿了,就是凑成等比数列的形式,知道了大概的方向,推导出来就不难了,只是当初想出这个方法的人值得膜拜。这里凑等比数列需要进行两次。众所周知,Fibonacci数列的递推式为:我们强制性凑等比数列(第一次),设:由于这个式子是由递推式变形得到的,所以有:解得

2015-04-04 16:12:55 1419

原创 主席树模版

参考wuyiqi#include #include #include using namespace std;const int maxn = 100010;int ls[maxn*20], rs[maxn*20], sum[maxn*20];int T[maxn], tot;void build(int l, int r, int& rt){ rt = ++tot; s

2015-03-24 16:33:56 1522

ACM 学习资料

ACM 学习资料 包括一些压缩包 和 数据结构的一点东西

2013-11-29

数据结构课件

数据结构的课件 感觉比书上的代码容易理解

2013-09-04

空空如也

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

TA关注的人

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