shyyhs
shyyhs
全部文章
题解
DP专题(52)
图论(4)
多校补题(2)
数据结构(27)
数论(4)
日记(14)
未归档(38)
归档
标签
去牛客网
登录
/
注册
shyyhs的博客
全部文章
/ 题解
(共329篇)
Paint Box
来自专栏
一直不是很懂容斥原理的原因,学二分图的时候再看看!我们很容易知道,求给n个位子上色,可以最多使用k种颜色的方案数是.由容斥原理想到可以把最多->等于.那么就是最多使用k种颜色-最多使用k-1种颜色+最多使用k-2种颜***r>那么直接这样做就好了.(值得注意的是:因为取模了,所以会存在负...
容斥原理
组合数学
2021-01-21
1
702
MMSet2
来自专栏
将求树的直径的过程进行模拟即可~ #include <bits/stdc++.h> using namespace std; const int N=3e5+50,M=20; vector<int>v[N]; int dep[N],w[N],f[N][M]; void dfs...
LCA
证明
2021-01-21
1
798
「火」皇家烈焰
来自专栏
直接按题意模拟dp即可.. #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e6+5,M=2; const int mod=1e9+7; char s[N]; ll f[N]...
dp
2021-01-20
3
737
珂朵莉的数列
来自专栏
emmm,我觉得是水题. 另外存下__int128的输入输出~好困啊! #include <bits stdc++.h> using namespace std; typedef long long ll; const int N=1e6+50; ll n; ll w[N],c[N],v...
树状数组
__int128
2021-01-20
1
865
Running Median
来自专栏
进阶指南原题(对顶堆一下.),原来快读可以减少空间. #include <bits/stdc++.h> using namespace std; inline int read() { int s = 0, w = 1; char ch = getchar(); whil...
优先队列
2021-01-20
1
808
过河
来自专栏
把数组开到极限,以及将可以在中间转化的值全部消除然后进行dp即可. #include <bits/stdc++.h> using namespace std; const int mod=2*3*4*5*6*7*8*9*2; const int N=1e2+5; const int M=...
dp
2021-01-20
3
655
背包
来自专栏
我觉得直接二分答案就好了,不需要讨论,只需要将数组按容量大小排序。我觉得答案是有二分性的。
二分
2021-01-18
2
807
旅游
来自专栏
思路: 简单的思考一下,这题就是没有上司的舞会.首先,我假如选了这个点,那么它的子节点都不能选,假如我这个点选了的话,那么它的子节点既可以选,又可以不选. 代码: #include <bits/stdc++.h> using namespace std; const int N=5e5+...
树形dp
2021-01-16
4
842
New Year Tree
来自专栏
回去再调. #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=4e5+5; ll col[N]; vector<int>g[N]; int now[N],last[N...
树链剖分
2021-01-15
2
704
[HAOI2006]旅行COMF
来自专栏
思路: 判断两点是否联通,可以用并查集来判断.如果起点和终点联通了,那么我们不妨枚举最大边是多少,然后按顺序枚举那条较小边是多少.然后取个min就是最终的答案了. 代码: #include <bits/stdc++.h> using namespace std; const int N=...
DSU
2021-01-14
3
699
首页
上一页
4
5
6
7
8
9
10
11
12
13
下一页
末页