题意 先枚举一个点必须选,设该点为$x$。 将两棵树都以$x$为根,对于点$y$,如果选$y$必须要选$fa_y$,于是就变成了了最大权闭合子图。 code: #include<bits/stdc++.h> using namespace std; const int maxn=55; const ...
分类:
其他好文 时间:
2020-06-05 21:04:56
阅读次数:
64
题目链接 C: 本题可以直接暴力求解,类比八皇后问题,使每个点分别对应一个值,分别判断有几条边能够满足即可 #include<bits/stdc++.h> using namespace std; #define ms(x,y) memset(x, y, sizeof(x)) #define low ...
分类:
其他好文 时间:
2020-06-05 20:56:25
阅读次数:
44
#神仙的博客(我就是用的这种方法) 树hash的方法很多,我用的是上面博客里面的方法 最近跟Wendigo神仙做题目,发现自己思维不行 #题目 ##BJOI2015树的同构 #include<bits/stdc++.h> typedef long long ll; using namespace s ...
分类:
其他好文 时间:
2020-06-05 20:51:17
阅读次数:
67
传送门 考虑转化为图的模型,不难发现题目要求的就是总边数。 我们定义两种边: 两个人单向关注:用单向边相连; 两个人互相关注:用双向边相连。 不难发现一个联通块内如果全都由双向边相连,那么就会自动连成一个完全图,它的贡献就是 \(siz(siz-1)\)。 于是我们考虑维护具有这样性质的联通块,我们 ...
分类:
其他好文 时间:
2020-06-05 20:48:08
阅读次数:
81
同 Luogu P3373 注意如果写 pushup 的话不要越界 注意更新 sum 值的位置 # include <iostream> # include <cstdio> # define MAXN 100000+5 # define LL long long using namespace s ...
分类:
其他好文 时间:
2020-06-05 19:30:00
阅读次数:
44
我好像只会背公式,用容斥来理解稍微好一点 程序的精妙的地方还是在其他部分,这个只不过是一个容斥 #题目 #游戏 #include<bits/stdc++.h> typedef long long ll; using namespace std; const int N=5100; const int ...
分类:
其他好文 时间:
2020-06-05 19:20:42
阅读次数:
68
题意 考虑点分治来枚举树上联通块,对于一个联通块,我们做有依赖性的树形DP即可,需要用单调队列优化多重背包。 有依赖性的树形DP code: #include<bits/stdc++.h> using namespace std; const int maxn=510; const int maxm ...
分类:
其他好文 时间:
2020-06-05 15:05:32
阅读次数:
53
#include <iostream> using namespace std; int main() { int n = 0, m; while(cin >> n){ m = n + 1; n % 2 == 0? n /= 2: m /= 2; cout << m * n << endl << e ...
分类:
其他好文 时间:
2020-06-05 13:20:48
阅读次数:
53
题意:n个数,选择2个长度为k的区间,求和最大。 区间大小固定,所以可以先求左区间最大,然后更新右区间。 注意有负数,初始化和枚举范围。 题目入口 #include <bits/stdc++.h> using namespace std; const int MAXN=2e5+10; typedef ...
分类:
其他好文 时间:
2020-06-05 12:58:38
阅读次数:
47
#include <iostream> #include <string> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define SWAP(a,b) auto c=a;a=b;b=c; int main() ...
分类:
其他好文 时间:
2020-06-05 12:52:35
阅读次数:
40