随笔分类 - 洛谷
摘要:数据范围小地可怜 那就模拟退火 #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; int ans[50]; int son[50
阅读全文
摘要:Archie 本文为倍增做法 后缀数组题 后缀数组是啥,把所有的后缀排个序就是后缀数组了 显然的暴力做法就是全部sort一遍 这不白瞎 我们利用倍增的思想,显然可以把一个字符串分成两半进行比较就可以了 引用一下wiki的图片。 这里有两个数组 $SA_i$表示第i小的后缀的编号 而$RK_i$表示第
阅读全文
摘要:Archie 这只是一道橙题,为什么我要写呢,。 因为这个题可以用基数排序做 以下做法为基数排序+计数排序 计数排序 和桶排有所相似 首先,统计每个值的出现次数 然后呢,在值域范围内统计次数的前缀和 然后从后往前扫并统计 for(int i=m;i>=1;--i){ b[tot[3][a[i]%10
阅读全文
摘要:Archie 当年咋就不加ull呢 很简单,按照二进制位拆就行了 /* �Һܱ�Ǹ */ #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<map> #include<stack> #
阅读全文
摘要:Archie 这是个什么东西呢 一看数据范围,肯定$o(n)$,带个$log$都不太肯能,再一看体面,y似乎没大有用 移项,发现$x+y=2z$这是啥意思呢,就是说,x+y需要是偶数,x,y奇偶性相同,颜色相同,那么我们何不把这些东西扔到一块去 然后,每与每一对数推式子,发现对于有k个数的堆,他的贡
阅读全文
摘要:splay splay与他的解析 二叉搜索树 我们搞一棵树,保证左子树所有点的权值比父亲小,右子树所有点权值比父亲大 显然这个玩意可以快速查询一个数存不存在,排名啦啥的 插入的时候直接顺序造节点,删除的时候,断开重连是件很愚蠢的事情 应该把删除节点和他右子树最左边那个或者左子树最右边那个交换,销毁它
阅读全文
摘要:Archie 怎样用模拟退火搞序列 随机交换就可以了 dp检查 #include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> using namespace std; int n,m
阅读全文
摘要:Archie 这叫啥啊,区间异或+区间求和 我用动态开点写的 #include<iostream> #include<cstdio> #include<algorithm> #define ll long long using namespace std; int n,m; int x,y,z; i
阅读全文
摘要:Archie 显然是要求逆序对的,这东西当然可以用树状数组求就可以了 然后呢,对于每一个点i,它为后面的点的话,那$j>i$的时候就会有贡献 扫就行了 #include<iostream> #include<cstdio> #include<algorithm> #define ll long lo
阅读全文
摘要:Archie 显然做法就是建反图,每个点都遍历一下,然后能过 然而有几个点死能卡常数,怎么办呢 干他 如果一头牛不能到达所有奶牛,它能到的所有牛都不行,同理,如果一头奶牛可以,它能到的所有牛都行 然而,这么干还是会被最后一个点干掉。 采用vector,对于每一个点的出边从小到大排序,因为最后枚举是
阅读全文
摘要:Archie 虽然只是个普通的普及 但我还要写一些 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; int n; string s[30]; bool cmp
阅读全文
摘要:Archie 出个好好的题卡什么输出格式 很简单的模拟退火 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #include<ctime> using namespac
阅读全文
摘要:Archie 很显然的换根dp #include<iostream> #include<cstdio> #include<cstring> using namespace std; int son[100001]; int dis[100001]; int n; int a,b; int head[
阅读全文
摘要:Archie 显然这玩意可以胡搞 怎么搞 模拟退火基本知识 #include<iostream> #include<cstdio> #include<algorithm> #include<cmath> using namespace std; double delat=0.993; double
阅读全文
摘要:Archie 拉格朗日插值法 知道了n个点的坐标,构造出一个n次多项式 然后求f(x) 公式 $ f_k=\sum_^ny_i\prod_{j=1\quad j\neq i }^n\frac$ 就行了 #include<iostream> #include<cstdio> #include<cstr
阅读全文
摘要:Archie 记忆化搜索就好 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; int m; int x; int a[10005]; int n,k; int
阅读全文
摘要:Archie 还是很水的 注意一下边界 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; int n,m; int d[10001]; int dp[10005
阅读全文
摘要:dpdpdp Archie 很显然,每一层之间有最优子结构 那么,怎么转移呢,既然两个方向,那就加一维从哪里走 #include<iostream> #include<cstring> #include<algorithm> #include<cstdio> #define int long lon
阅读全文
摘要:Archie 首先很显然的是,无论怎么选,这里肯定会有一条贯穿的横向和一条纵向的骨架 那么问题来了,剩下的呢 按照大小一个一个插,不要有环出现 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #def
阅读全文
摘要:P2736 [USACO3.4]“破锣摇滚”乐队 Raucous Rockers 死小的数据范围 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; int n,
阅读全文