06 2019 档案

摘要:A 略 B 被删了,被这个假题搞自闭了,显然没做出来。 C 开始莽了个NTT,后来发现会TLE,其实是个SB前缀和,对于这题,我无**说。 #include<bits/stdc++.h> using namespace std; const int N=1e6+7,mod=998244353; in 阅读全文
posted @ 2019-06-28 18:59 hfctf0210 阅读(313) 评论(1) 推荐(0)
摘要:min25筛简介:用来求积性函数F(x)前缀和的,复杂度O(n0.75/logn),大概能求n<=1010。 记一个数x的最小质因子为R(x),所以当x不为质数时,R(x)<=√x这是废话。 首先求所有质数的F(x)和,下设g(i,j)=ΣF(x),其中2<=x<=i,且x为质数或R(x)>pri[ 阅读全文
posted @ 2019-06-25 17:51 hfctf0210 阅读(227) 评论(0) 推荐(0)
摘要:这场和div3差不多嘛(后来发现就是div3),就是网太卡10min交一发就不错了,简直自闭。 A 签到。 B 记录每一段的字母数,满足条件即:段数相同+字母相同+字母数下>=上。 #include<bits/stdc++.h> using namespace std; const int N=1e 阅读全文
posted @ 2019-06-20 08:51 hfctf0210 阅读(445) 评论(0) 推荐(0)
摘要:这题看题面感觉挺玄学的,但其实会挂链式hash就能暴力切了,就是纸老虎,考察选手的语文水平。不过三年没写挂链hash也应该写一下了…… 首先模数设成自然溢出ull,然后挂链时的模数取2^24。然后就可以直接hash了。对于3操作直接O(Σ|S|)询问即可,对于1、2操作,直接暴力加、减长度不超过50 阅读全文
posted @ 2019-06-19 11:29 hfctf0210 阅读(305) 评论(0) 推荐(0)
摘要:第二道线段树分治。 首先设当前向量是(x,y),剩余有两个不同的向量(u1,v1)(u2,v2),假设u1>u2,则移项可得,若(u1,v1)优于(u2,v2),则-x/y>(v1-v2)/(u1-u2),然后维护上凸壳后进行三分即可,复杂度O(nlog2n),如果将询问排序扫一遍,可以优化到O(n 阅读全文
posted @ 2019-06-18 11:35 hfctf0210 阅读(258) 评论(0) 推荐(0)
摘要:重新写一年前抄题解的那题,当时我啥都不会只是Ctrl+C,Ctrl+V写过的题,今天重新写一遍。 题解: 不会线段树分治,还是学一下这东西吧,这是我的第一道线段树分治。 首先对于特殊商品,可以直接可持久化Trie记录答案。首先考虑对每个线段树开一个vector,把询问的时间区间看成一段一段的塞到线段 阅读全文
posted @ 2019-06-17 23:03 hfctf0210 阅读(159) 评论(0) 推荐(0)
摘要:怕不是最后一篇(雾),过滤最基础的背包DP、状压DP、递推等 树上换根DP:https://www.luogu.org/problemnew/show/P4284 数位DP:http://www.51nod.com/Challenge/Problem.html#!#problemId=1245 斜率 阅读全文
posted @ 2019-06-17 14:18 hfctf0210 阅读(156) 评论(0) 推荐(0)
摘要:最裸的莫队:https://www.luogu.org/problemnew/show/P1494 树上莫队:https://www.luogu.org/problemnew/show/P4074 带修莫队:https://www.lydsy.com/JudgeOnline/problem.php? 阅读全文
posted @ 2019-06-17 14:02 hfctf0210 阅读(147) 评论(0) 推荐(0)
摘要:此处过滤最水的匈牙利算法。 最大流&最小割:https://www.lydsy.com/JudgeOnline/problem.php?id=2127 费用流:https://www.luogu.org/problemnew/show/P3705 KM:https://www.luogu.org/p 阅读全文
posted @ 2019-06-17 13:45 hfctf0210 阅读(126) 评论(0) 推荐(0)
摘要:一些不知怎么分类的算法。 huffman树:https://www.luogu.org/problemnew/show/P2168 矩阵树定理:https://www.luogu.org/problemnew/show/P4111 分数规划:https://www.luogu.org/problem 阅读全文
posted @ 2019-06-17 13:28 hfctf0210 阅读(132) 评论(0) 推荐(0)
摘要:meet in the middle:https://www.lydsy.com/JudgeOnline/problem.php?id=4800 CDQ分治:https://www.luogu.org/problemnew/show/P3810 点分治:https://www.lydsy.com/J 阅读全文
posted @ 2019-06-17 13:25 hfctf0210 阅读(190) 评论(0) 推荐(0)
摘要:去除过水的模板,包括但不限于dijkstra(甚至堆优化都被过滤了)、SPFA、kruskal、拓扑排序等。 欧拉回路:http://uoj.ac/problem/117 混合图的欧拉路:https://www.lydsy.com/JudgeOnline/problem.php?id=2095 强连 阅读全文
posted @ 2019-06-17 11:08 hfctf0210 阅读(241) 评论(0) 推荐(0)
摘要:过滤一些较简单的如线段树、树状数组等,甚至树链剖分都被过滤了。 左偏树:https://www.luogu.org/problemnew/show/P3377 主席树:https://www.luogu.org/problemnew/show/P3834 可持久化并查集:https://www.lu 阅读全文
posted @ 2019-06-17 11:07 hfctf0210 阅读(241) 评论(0) 推荐(0)
摘要:可能是血(水)考前最后一篇题解了,不过还是写写题解吧。 大部分来源51nod 51nod1253 Kundu and Tree 挺思博的一道题。首先黑色边没用,所以可以把其视为连通块,然后走出该连通块必然要经过至少一条红色边,于是就是总方案数减3个全在一个黑连通块再减去2个在一个黑连通块。 #inc 阅读全文
posted @ 2019-06-16 23:19 hfctf0210 阅读(198) 评论(0) 推荐(0)
摘要:A 签到(code不贴了) PS:以后cf div2A(有时还有B)和atcoder <=200分(有时<=300)的题目不再贴code,不过可能也没几次比赛记录了。 B 高精度,枚举位数最短的可能,然后计算两个即可。 #include<bits/stdc++.h> using namespace 阅读全文
posted @ 2019-06-16 22:34 hfctf0210 阅读(254) 评论(0) 推荐(0)
摘要:A 签到(a-b problem不用贴了吧,以后atcoder小于300分题均不贴代码) B 发现选择的p,q一定是其中两点间的距离,于是可以O(n2)枚举两点,再O(n2)判断,其实可以做到O(n3)不过O(n4)就够了。 #include<bits/stdc++.h> using namespa 阅读全文
posted @ 2019-06-16 08:53 hfctf0210 阅读(174) 评论(0) 推荐(0)
摘要:这题其实挺经典的,看到求异或最大,显然想到的是线性基,不过这怎么维护?当然区间有关的东西都可以上线段树,区间修改时记录每个点的修改量k,然后合并线性基时再加入线性基。因为线性基是求一组极大线性无关组,所以查询a[i]^k组成的线性基等价于查询k∪a[i]。 #include<bits/stdc++. 阅读全文
posted @ 2019-06-15 13:08 hfctf0210 阅读(233) 评论(0) 推荐(0)
摘要:A 签到 #include<bits/stdc++.h> using namespace std; char s[200002]; int n,a[20]; int main() { scanf("%s",s+1); n=strlen(s+1); for(int i=1;i<=n;i++)a[s[i 阅读全文
posted @ 2019-06-15 11:30 hfctf0210 阅读(231) 评论(0) 推荐(0)
摘要:首先可以转化问题,变为对每种颜色分别考虑不含该颜色的简单路径条数。然后把不是当前颜色的点视为白色,是当前颜色的点视为黑色,显然路径数量是每个白色连通块大小的平方和,然后题目变为:黑白两色的树,单点翻转颜色,维护白色连通块大小平方和,然后根据Auuan大佬的题解,我用了LCT。就是对每个点维护子树、儿 阅读全文
posted @ 2019-06-13 18:51 hfctf0210 阅读(464) 评论(0) 推荐(0)
摘要:AB 签到(A过水已隐藏) #include<bits/stdc++.h> using namespace std; const int N=505; int n,m,vis[N][N]; char mp[N][N]; int main() { scanf("%d%d",&n,&m); for(in 阅读全文
posted @ 2019-06-12 09:38 hfctf0210 阅读(265) 评论(0) 推荐(0)
摘要:蒟蒻又发现自己还没写过LCT…… 首先显然按照权值a从小到大排序,维护b的最小生成树。然后直接扫,代价是加入b的最大值,然后动态加边,因为有边权,所以在lct中边应该理解为点。每次连接(u,v)时,若不连通则直接连起来,反之则需选择b最大的边断开。 #include<bits/stdc++.h> u 阅读全文
posted @ 2019-06-10 11:17 hfctf0210 阅读(201) 评论(0) 推荐(0)
摘要:ABCD 签到(A、B、C过水已隐藏) #include<bits/stdc++.h> using namespace std; const int N=2003; int n,m,ans,f1[N][N],f2[N][N],f3[N][N],f4[N][N]; char mp[N][N]; int 阅读全文
posted @ 2019-06-09 22:17 hfctf0210 阅读(400) 评论(0) 推荐(0)
摘要:太难的比如三维凸包已过滤,估计NOI考不了毒瘤计算几何吧,不过还是背些简单的吧。 二维凸包:https://www.luogu.org/problemnew/show/P2742 旋转卡壳:https://www.lydsy.com/JudgeOnline/problem.php?id=1185 半 阅读全文
posted @ 2019-06-08 21:30 hfctf0210 阅读(199) 评论(0) 推荐(0)
摘要:你永远不会相信一个快AFO的选手不会可持久化Trie。 其实异或粽子那题可以用可持久化Trie做,不过我还是没用,用的一般的Trie(其实可持久化是多此一举),于是到现在还是不会可持久化Trie。 这题首先可以发现要求的是最大值,所以很多区间是没必要的,l1[i]/r1[i]表示左/右边第1个比a[ 阅读全文
posted @ 2019-06-08 20:56 hfctf0210 阅读(207) 评论(0) 推荐(0)
摘要:没有SPJ时显然是不需要输出方案的。不需要输出方案很好做,先把边扩展(因为会往下流),然后求最大独立集,最大独立集=n-最小点覆盖,因为其是最大独立集的补集。如何求最小点覆盖呢?毕竟我写过最大权闭合子图的:http://www.51nod.com/Challenge/Problem.html#!#p 阅读全文
posted @ 2019-06-08 17:06 hfctf0210 阅读(215) 评论(0) 推荐(0)
摘要:挂链式hash:https://www.luogu.org/problemnew/show/P3823 最小表示法:https://www.luogu.org/problemnew/show/P1368 KMP:https://www.luogu.org/problemnew/show/P3375 阅读全文
posted @ 2019-06-08 11:15 hfctf0210 阅读(205) 评论(0) 推荐(0)
摘要:A 太难了,一半时间刚这题还没做出来,简直自闭了。实际上分两种情况,一种很简单直接放,另一种就是要0,0,…,0,1,2,…,n,然后直接贪心,显然我是把情况判断错误一直没调出来。 #include <bits/stdc++.h> using namespace std; const int N=2 阅读全文
posted @ 2019-06-08 10:39 hfctf0210 阅读(314) 评论(0) 推荐(0)
摘要:温馨提示:本题十分卡常数,我手动开O2才过的。而数据范围不伦不类的n<=30000,常数小的O(n2)居然比O(n√nlogn)跑得快…… 考虑插进去一个元素对答案产生的影响。原本数列为Σa[i]f[i],其中1<=i<=n,然后考虑在k位置插入a[0],答案显然是a[1]f[1]+a[2]f[2] 阅读全文
posted @ 2019-06-07 10:17 hfctf0210 阅读(283) 评论(0) 推荐(0)
摘要:要是有题目FST了就重新写 A 签到 #include<bits/stdc++.h> using namespace std; int T; long long n,k,ans; int main() { cin>>T; while(T--) { cin>>n>>k,ans=0; while(n) 阅读全文
posted @ 2019-06-06 09:58 hfctf0210 阅读(321) 评论(0) 推荐(0)
摘要:一些NOIP难度的 exgcd excrt(今年考的可能性不大因为NOI2018考过了,不过还是复习万一能骗分呢?):https://www.luogu.org/problemnew/show/P4777 数论分块+莫比乌斯反演:https://www.lydsy.com/JudgeOnline/p 阅读全文
posted @ 2019-06-05 18:16 hfctf0210 阅读(297) 评论(0) 推荐(0)
摘要:FFT:https://www.lydsy.com/JudgeOnline/problem.php?id=2179 NTT与FFT类似就没了 分治NTT:https://www.luogu.org/problemnew/show/P4721 FWT:https://www.luogu.org/pro 阅读全文
posted @ 2019-06-05 10:22 hfctf0210 阅读(183) 评论(0) 推荐(0)
摘要:题意:重新解释一下题意吧(题意晦涩难懂) 给定n个单词,你可以按照顺序学习,当学习这一单词时,这个单词是第x个要学习的单词,需要的代价分三类: 1、若存在其他单词是其后缀没被学习,则代价为n2 2、若不存在其他单词是其后缀,则代价是x 3、否则代价是x-y(y是最靠后的是其后缀的单词学习的位置) 题 阅读全文
posted @ 2019-06-05 10:04 hfctf0210 阅读(218) 评论(0) 推荐(0)
摘要:网太卡只好做划水选手,只做EF。 E 很容易发现第一个数是2k或者是3*2k-1,因为消去因子次数要尽可能多,然后可以直接dp一发转移还剩几个2/3即可,写起来有些麻烦 #include<bits/stdc++.h> using namespace std; const int N=1e6+7,mo 阅读全文
posted @ 2019-06-05 09:47 hfctf0210 阅读(161) 评论(0) 推荐(0)
摘要:老年选手需要多写一些思维题qwq。 通过打表很容易发现对于(i,j),值为(i-1)^(j-1)+1,然后本题就没了qwq。 矩阵差分还是很容易想到的,容斥成四个矩阵。 然后看到异或很容易想到三件事:数位DP、字典树、线性基。很容易发现后两种与本题不符,就是数位DP了,从高位到低位DP,f[i][0 阅读全文
posted @ 2019-06-04 20:03 hfctf0210 阅读(444) 评论(3) 推荐(0)
摘要:A 签到,开long long(不开也pp不了) #include<bits/stdc++.h> using namespace std; long long a,b,ans; int main() { cin>>a>>b>>ans;ans*=2; if(a==b)ans+=a*2; else an 阅读全文
posted @ 2019-06-02 09:07 hfctf0210 阅读(309) 评论(2) 推荐(0)
摘要:AB 签到(A就是ans=180(n-2)所以不放code了) #include<bits/stdc++.h> using namespace std; int n,ans; char s[100001]; int main() { scanf("%s",s+1); n=strlen(s+1),an 阅读全文
posted @ 2019-06-02 08:54 hfctf0210 阅读(213) 评论(0) 推荐(0)
摘要:非常抱歉,这篇文章鸽了。 阅读全文
posted @ 2019-06-01 18:30 hfctf0210 阅读(447) 评论(0) 推荐(0)