11 2020 档案
摘要:题意: 给定一个三维整点空间,空间中的点分为三类:空地,用户,分配站。一个用户到分配站的距离定义为两者的曼哈顿距离,一个用户的贡献定义为他到所有分配站的最短距离。问再在一个空地上加入一个分配站可以使得所有用户贡献的最小值为多少? 思路: 二分答案,只要考虑当前贡献大于答案的那些用户即可。 该题的关键
阅读全文
摘要:struct UFS { stack<pair<int*, int> > stk; int fa[maxn], rnk[maxn]; inline void init(int n) { for (int i = 0; i <= n; ++i) fa[i] = i, rnk[i] = 0; } inl
阅读全文
摘要:/* 询问每个节点子树上的颜色数 */ #include <bits/stdc++.h> using namespace std; const int maxn=1e5+5; struct edge{ int v,next; }E[maxn<<1]; int head[maxn],tot=0; vo
阅读全文
摘要:数位DP https://loj.ac/problems/tag/104 状压DP https://loj.ac/problems/tag/32,33
阅读全文
摘要:数位DP模板 //求l~r所有数的数位和之和 #include <bits/stdc++.h> using namespace std; typedef long long ll; const int mod=1e9+7; int a[25],len; int dp[25][2][200]; int
阅读全文
摘要:题意: 一个数如果没有任何两位的数字是相同的,则该数称为B数,有两种询问: 问[a,b]区间有多少个B数(在10/16进制下) 问第k个B数是什么(在10/16进制下) 思路: 显然第一类问题可以用数位DP求解,第二类问题就是在数位dp外面套个二分就可以求解。由于输入的数都是unsigned lon
阅读全文
摘要:debug #define debug(x) cerr << #x << " = " << x << ' ' #define debugl(x) cerr << #x << " = " << x << '\n' 状压dp int test(int x, int y) { return x >> y
阅读全文
摘要:题意: 给定n,在x轴[0,n]范围内画半径不超过5的圆,圆心在x轴上,要求任意两个圆不相交(可以相切),且已有固定的k个圆,求满足条件的画法方案数。 题解: 先不管已存在的圆考虑从左往右dp,dp[i]表示以i为右边界的方案数,显然从dp[i-1]到dp[i]的转移只和以i为右边界的圆有关,而圆的
阅读全文
摘要:// cin,cout加速(不能和scanf混用,换行要用endl) ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); namespace Fast_IO{ const int MAXL((1 << 18) + 1);int io
阅读全文

浙公网安备 33010602011771号