随笔分类 - 题 / 算法
摘要:https://www.luogu.com.cn/problem/P1836 这是数位dp吗 这布什打表+暴力吗 #include<bits/stdc++.h> using namespace std; long long n; int sum[10]={0,1,3,6,10,15,21,28,36
阅读全文
摘要:先说几句: yzc太唐了 老实了 1.思路 这道题用小脑子想一想,可知是最小割 我们先假设能满足所有组合 然后再把它割掉 评论区给出了三倍经验,P4313和P1646。 具体思路如下: 我们把每一个人视作一个点 \(i\),规定:\(i\)被割到\(S\)集里,代表这个人选文,\(i\)被割到\(T
阅读全文
摘要:一个朴素的想法:根据时间t来dp: f[t][i][j]表示在第t时刻在第i行第j列所能获得的最长距离。 转移方程:f[t][i][j]=max(f[t-1][i][j],f[t][i][j]+1)(i,j为上一个合理的位置) 但O(TMN),包炸的牢底。 所以必须优化,首先把时间t换成区间k, 令
阅读全文
摘要:【模板】字符串哈希 竟然没写,干了 #include<bits/stdc++.h> using namespace std; long long base=131,a[10010],mod=212370440130137957ll; char s[10010]; int n,ans=1,prime=
阅读全文
摘要:作为带权并查集的模板题,当然要先烧烤,再Σ了 看这: 更新很容易,我们来分析一下:对于原来的队头,它到队头的距离为0,当将它所在的队列移到另一个队列后面时,它到队头的距离就是排在它前面的飞船数,也就是合并前另一个队列的飞船数量。因此,就知道该怎样实现了,我们再建一个数组num,num[i]表示以i为
阅读全文
摘要:暴搜+剪枝,Σ了 #include<bits/stdc++.h> using namespace std; int n,m,a[70],nt[70],cnt,ans,len; bool used[70],ready; bool cmp(int a,int b){ return a>b; } void
阅读全文
摘要:模板拓扑(或许) #include<bits/stdc++.h> using namespace std; struct edge { int to,val,nxt; } e[10005]; struct answer { int id,val; } ans[105]; int h,m,n,t,u,
阅读全文
摘要:最大生成树+lca。 参考资料 思路 首先便是想到了Floyd的暴力方法,状态转移方程也不难推出:w[i][j]=max(w[i][j], min(w[i][k],w[k][j]));但是n3次方时间复杂度和n2的空间复杂度是显然不可取的。 于是我们思考,可以发现有一些权值较小的边是不会被走过的。正
阅读全文
摘要:早过了,但O2会爆 于是进行面向题解的编码 裸kruskal #include<bits/stdc++.h> using namespace std; struct node { int x,y,s; } d[200000]; int n,m,ans,num,f[1000],w,k,c; bool
阅读全文
摘要:题目题解 but my code is outing #include<bits/stdc++.h> using namespace std; const int B=2e9; struct dot{ int x,y; }a[200010],ddt[200010]; inline int ass(i
阅读全文
摘要:105,一眼nlogn。 考虑能不能写线段树(毕竟我只会这一种树状结构)。 发现很难想…… 看来得靠分治了 复习一手CDQ ??? 看了一眼题解 原来,我只是没想到前缀和,嘤嘤嘤 然后就成归并排序求逆序对了,只不过要加上0 然而90pts??? 不开ll见祖宗啊…… 简单放个代码 #include<
阅读全文

浙公网安备 33010602011771号