自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

KGV093的博客

Revelations and heartaches, make you realize.

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

原创 NOIP 2017总结

NOIP一周以后CDQZ_GXOI队再一次重聚在机房,也许这是最后一次在机房看见大部分昔日的战友。与往日不同的是,大多数身旁的人都是省一,而本人并不是。 官方成绩是30+190=220分,也许历史上很少有人考出类似的分数(估计去年来考第一天都有100多分),就连hfu老师都又气又笑地问我:“你介(这)个第一天整(怎)么连山(三)~~~十分都考出来啦?!”。第二天破釜沉舟拼来一个正常的分数,...

2017-11-21 21:48:55 533

原创 codevs 2178(中缀表达式求值)

中缀表达式a + b*c + (d * e + f) * g,其转换成后缀表达式则为a b c * + d e * f + g * +。 转换过程需要用到栈,具体过程如下: 1)如果遇到操作数,我们就直接将其输出。 2)如果遇到操作符,则我们将其放入到栈中,遇到左括号时我们也将其放入栈中。 3)如果遇到一个右括号,则将栈元素弹出,将弹出的操作符输出直到遇到左括号为止。注意,左括号只弹出并不

2017-11-10 21:58:55 488

原创 Luogu 3371(dijkstra堆优化)

传送门模板题。此版本无遍历标记,只能过弱化版数据......#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<queue>using namespace std;const int N=10004,M...

2017-11-09 21:27:31 331

原创 hihocoder 1043(完全背包)

传送门模板题,正着for。#include#include#include#includeusing namespace std;int c[502],v[502];int n,m;int f[100004];inline int read() { int x=0;char c=getchar(); while (c'9') c=getchar(); while (c

2017-11-09 20:40:32 295

原创 hihocoder 1038(01背包)

传送门模板题,倒着for,复杂度O(n*maxV)。#include#include#include#includeusing namespace std;int c[502],v[502];int n,m;int f[100004];inline int read() { int x=0;char c=getchar(); while (c'9') c=getch

2017-11-09 20:36:39 227

原创 hihocoder 1098(kruskal)

传送门模板题,原计划觉得kruskal稳如狗根本不用管,但是保险起见还是敲一遍,如果忘了就吃键盘。#include#include#include#includeusing namespace std;const int N=1e5+4,M=1e6+4;int n,m,fa[N];struct EDGE { int u,v,w; friend bool operator

2017-11-09 19:57:18 293

原创 hihocoder 1032(manacher)

传送门模板题。关键:记一个最远延伸的起点id。#include&lt;cstdio&gt;#include&lt;cstring&gt;#include&lt;iostream&gt;#include&lt;algorithm&gt;using namespace std;const int N=1e6+4;char s[N];int p[N&lt;&lt;1];in...

2017-11-09 19:46:07 295

原创 hihocoder 1015(KMP)

传送门再刷模板ing。#include#include#include#includeusing namespace std;char T[1000004],W[10004];int n,m,f[10004];inline void getfail(char *W,int m) { f[0]=f[1]=0; for (register int i=1;i<m;++i)

2017-11-09 19:24:51 222

原创 hihocoder 1014(Trie)

传送门Trie树模板题,询问一个前缀在字符串集合中出现的次数。#include#include#include#includeusing namespace std;const int N=1e6+4;struct Trie { int ch[26][N]; int val[N],tot; inline Trie() {memset(ch,-1,sizeof(ch))

2017-11-09 19:13:27 236

原创 Luogu 1514(BFS+贪心)(NOIP 2010)(引水入城)

传送门题意:一个N*M矩形,每个格子有一个海拔,需要在第一行恰当位置建水利设施将水引到最后一行的每个格子。有两种设施:抽水站,可以建在第一行任意位置;引水站,只要它周围存在一个格子比它地势高且那个格子建的有任意一种水利设施,就可以建造,建造后水引到这里。第一行输出1/0代表能否使得后一行全部引到水。如果是1,求最少需要多少抽水站;如果无法满足,输出最多有多少个无法供水的位置。题

2017-11-09 17:26:49 293

原创 UOJ 260(模拟)(玩具谜题)

传送门只求NOIP D1T1稳过orz。#include#include#include#includeusing namespace std;const int N=1e5+4;int n,m;struct Node { int w; char s[14];}a[N];int main() { scanf("%d%d",&n,&m); for (regist

2017-11-08 21:26:08 218

原创 Luogu 3383(线性筛)

传送门模板题。好奇NOIP会不会考用线性筛求一个化简过程中遇到的积性函数#include#include#include#includeusing namespace std;const int N=1e7+4;int prime[N/10],tot=0;bool vis[N];inline void linear_shaker(int n) { vis[1]=tru

2017-11-08 19:20:43 248

原创 NOIP-The Final Week 总结

最后一周如期到来。最近几场考试也没有发挥得太好,也不知道是不是因为“死猪不怕开水烫”,心里不怎么慌了。不过话说回来,个人感觉NOIP真的不会这么重思维轻代码。三天考试好像没有一道代码量100行以上的题。但是,现在要做的毕竟是做好应对各种题的准备,所以思维题也必须认真地想清楚。后面几天继续复习模板和做过的思维题,然后还有一件大事就是要多睡一点,每天22:50之前必须碎!再说一点干货:1.根号

2017-11-08 16:19:15 207

原创 Luogu 3805(manacher)

传送门模板题。注意:id要初始化为0,否则本地都会RE(局部变量的初值不会自动为0)。P.S.本文可能是本菜鸡AFO之前最后一篇(或者几篇)博文。7月底开始写博客时第二篇便是manacher,现在以此收尾,不得不感叹时间飞逝~~最后几天好好努力吧!#include#include#include#include#include#includeusing namesp

2017-11-07 20:05:57 155

原创 Luogu 3865(st表)

传送门模板题,就怕某些毒瘤出题人卡线段树。#include#include#include#includeusing namespace std;const int N=1e5+4;int n,q;int mx[18][N],lg[N]={0,0};inline int read() { int x=0;char c=getchar(); while (c'9') c=

2017-11-07 19:28:36 243

原创 Luogu 3807(Lucas定理)

传送门模板:同时用于复习阶乘以及逆元的预处理。#include#include#include#includeusing namespace std;typedef long long ll;const int N=1e5+4;int fac[N<<1]={1,1},inv[N<<1]={1,1};int n,m,mod;inline int read() { in

2017-11-07 19:08:34 253

原创 Luogu 3386(二分图最大匹配)

传送门模板题。新技能get:存增广标记的cov数组如果使用int类型就不用每次memset(以前的版本在之前的博文中有过),可以大幅节约时间。晚安~#include#include#include#include#includeusing namespace std;const int N=1004;int n,m,eg;int head[N<<1],etot=0;

2017-11-06 22:25:59 273

原创 Luogu 3382(三分)

传送门模板题。好想有个什么叫黄金分割比例优化三分,洛谷的题解里有一位大佬提到过orz。#include#include#include#includeusing namespace std;const int N=15;const double eps=1e-10;double a[N],L,R;int n;inline double fpow(double a,in

2017-11-06 22:02:59 203

原创 Luogu 3381(最小费用流)

传送门模板题。最小费用最大流,要求同时输出最大流以及最小费用,复杂度有点玄学,每增广一次,下一次SPFA的复杂度又会降低。所以这种题暂时只能这么处理:看出来有后效性的相互约束关系的就考虑用费用流解决。#include#include#include#include#includeusing namespace std;const int N=5004,M=50004,INF=0

2017-11-06 21:24:42 242

原创 Luogu 3375(KMP)

传送门KMP模板题,要求输出匹配点的起始位置以及模式串所有位置的nxt(也称作fail)指针。#include#include#include#include#include using namespace std;const int N=1e6+4;char T[N],W[N];int n,m,f[N];vector s;inline void getfail(cha

2017-11-06 20:50:12 199

原创 Luogu 3376(最大流)(Dinic+当前弧优化)

传送门Dinic+当前弧优化,复杂度上界为O(V^2*E),NOIP应该还不至于卡这个而支持ISAP吧。#include#include#include#include#includeusing namespace std;const int N=1e4+4,M=1e5+4,INF=0x3f3f3f3f;int n,m,source,sink;int head[N]

2017-11-06 20:31:50 355

原创 Luogu 3390(矩阵快速幂)

传送门模板题,注意取模以及快速幂中需ret初始化成单位矩阵才能操作。P.S.懒得封装了,估计NOIP考到这玩意我也没闲心去重载个什么乘法。。。#include#include#include#includeusing namespace std;const int N=104,MOD=1e9+7;typedef long long ll;int n;struct M

2017-11-06 20:06:03 193

原创 Luogu 3388(割点)

传送门注意:统计割点个数一定要注意算重!!!有多个儿子使当前点成为割点时计数器也只能加一次!!!#include#include#include#includeusing namespace std;const int N=1e5+4;int n,m,dfn[N],low[N],tim=0,cut=0;int head[N],etot=0;struct EDGE { in

2017-11-06 19:40:37 288

原创 Luogu 3379(LCA)

传送门模板题,我用倍增居然把它卡过了。(拒绝vector支持链式前向星!)P.S.在欧拉序列上进行RMQ也可以做到O(1)。倍增:#include#include#include#includeusing namespace std;const int N=5e5+4;int n,q,rot;int dep[N]={0},f[20][N];int head[N],e

2017-11-06 17:14:07 257

原创 Luogu 3384(树链剖分)(模板)

传送门模板题,其中线段树部分也可以使用树状数组实现(区间操作略显麻烦)。#includeusing namespace std;#define lson rt<<1,l,mid#define rson rt<<1|1,mid+1,r#define root 1,1,ntypedef long long ll;const int MAXN=1e5+4;int rot,n,m,a

2017-11-05 23:03:25 234

原创 Luogu 3370(hash)

传送门模板题,如果有误请各位大佬直接打脸,毕竟这类算法以前基本没碰过。P.S.本题还可以用stl的set直接搞,更快更短orz。#include#include#include#includeusing namespace std;typedef unsigned long long ull;const int N=1e4+4;const ull base=263;

2017-11-05 22:48:04 224

原创 Luogu 3378(堆)

传送门模板题。#include#include#include#includeusing namespace std;const int N=1e6+4; struct Heap { int a[N],siz=0; inline void push(int x) { a[++siz]=x; push_heap(a+1,a+siz+1,greater()); }

2017-11-05 16:55:41 238

原创 Luogu 3373(线段树标记混合下传)

传送门题意:nlogn实现区间加、区间乘、区间求和(都要求取模)题解:只要记住一句话:(x+a)*b=x*b+a*b,先乘后加,乘法标记管两个(sum,add),加法标记管一个(sum)。#include#include#include#includeusing namespace std;#define root 1,1,n#define lson rt<<1,l

2017-11-05 16:20:37 273

原创 11.3~11.4NOIP模拟测试总结

也许这是最后一次面对夕阳走出科技楼,当然,现在所做的一切都是让之前的努力收到回报并努力让这“”最后一次“”不成为真正的最后一次。昨天考试第二题没做出来是因为一看到序列上大小关系就想到跟拓扑有关的图论,其实稍微推一下性质就能搞出来,说明以后想清楚一个题后一定要跳出来再多角度考虑一下,选取尽量科学的策略来解决问题。今天本以为可以AK的,但是真的由于经验不足,检查时没有查出数组定义的小错误(M写成N

2017-11-04 17:14:51 219

原创 bzoj 4034(树链剖分)

传送门考前复习模板题(子树修改,单点修改,链上求和)。一晚上狂TLE,原因竟是:链剖siz比较写错,写了个轻链剖分。。。#includeusing namespace std;#define lson rt<<1,l,mid#define rson rt<<1|1,mid+1,r#define root 1,1,ntypedef long long ll;const i

2017-11-03 20:46:16 229

原创 Luogu 2827/bzoj 4721(单调队列)

传送门题解:如果x>y,显然x*p+q>(y+q)*p,所以:如果优先选最长的切,那么次长蚯蚓的子段一定也在最长蚯蚓的子段之后,所以用三个单调递减队列维护长度(原长,前半截,后半截),每次选三个队首最大的那个,切成两段扔进后两个队列,此时队列一定仍满足单调性。差不多就是个模拟题。。。P.S.上bzoj交的要注意处理行末空格以及回车,但在洛谷必须保留。。。Luogu 2827

2017-11-03 16:45:18 237

原创 11.1~11.2NOIP模拟赛总结

虽说是原创题,但是并不觉得针对性有多强,还怀疑我们校区泄露内部资料ㄟ( ▔, ▔ )ㄏ。第一试的暴力没写是本次考试最大的败笔,当场做出这样决定的原因是暴力的理论复杂度1分都拿不到,但是实际测试数据暴力分部分的强度只有题面上的50%左右,所以能过40分。第二试除了暴力写挂了以外,也没有别的什么意外发生,就是需要再加强对期望的理解。以后考试只有有时间不管啥题,不管理论复杂度如何都要交个暴力上去

2017-11-02 21:18:52 292

原创 bzoj 2815(LCA+拓扑排序)(灭绝树)

传送门题意:在一个DAG中,问一个点是多少个点的支配点?题解:好像灭绝树就是因为这题被发明的。在DAG上拓扑排序时,通过在反图上倍增计算所有前驱的LCA,在新图(灭绝树)中add_edge(LCA,当前点)。最后对于每个点输出它在灭绝树上的子树大小-1(自己不算)。#include#include#include#include#include#include

2017-11-02 19:01:48 274

空空如也

空空如也

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

TA关注的人

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