A. Balance 不难发现确定第一行第一列后即可确定全部,列不等式单纯形求解线性规划即可. #include<cstdio> #include<algorithm> using namespace std; typedef long long ll; typedef vector<double>VD; const int N=110; const double eps=1e-9; VD simplex(vector<VD>A, VD b, VD c){…
A. Nutella’s Life 斜率优化DP显然,CDQ分治后按$a$排序建线段树,每层维护凸包,查询时不断将队首弹出即可. 时间复杂度$O(n\log^2n)$. #include<cstdio> #include<algorithm> using namespace std; typedef long long ll; typedef pair<int,int>P; const int N=100010,M=262150; int n,i,a[N],cb;ll…
contest Link A. Base i − 1 Notation solved by sdcgvhgj 238 求出a+b的2进制后从低位到高两位两位地转化为i-1进制 i-1进制的第2k位和第2k+1位只有唯一的填法使2进制的第k位不留遗憾地攀登到高位 B. Squaring a Bit solved by rdc 77 本地打表,交表. C. Chickens solved by rdc, 24 f[i][mask] 表示前 i 个物品匹配 mask 集合的方案数. D. Lights…
A. Base $i - 1$ Notation 两个性质: $2=1100$ $122=0$ 利用这两条性质实现高精度加法即可. 时间复杂度$O(n)$. #include<stdio.h> #include<iostream> #include<string.h> #include<string> #include<ctype.h> #include<math.h> #include<set> #include<…
A. Accommodation Plan 对于已知的$K$个点,离它们距离都不超过$L$的点在树上是一个连通块,考虑在每种方案对应的离$1$最近的点统计. 即对于每个点$x$,统计离它距离不超过$L$的点数$call[x]$,再减去离它和它父亲距离都不超过$L$的点数$cext[x]$,然后用组合数计算方案数. 对于$call[x]$可以通过点分治+排序双指针$O(n\log^2n)$统计. 对于$cext[x]$,注意到$cext[x]=call[x]-csub[x]$,其中$csub[x]…
1. GUI 按题意判断即可. #include<stdio.h> #include<iostream> #include<string.h> #include<string> #include<ctype.h> #include<math.h> #include<set> #include<map> #include<vector> #include<queue> #include&l…
A. City Wall 找规律. #include<stdio.h> #include<iostream> #include<string.h> #include<string> #include<ctype.h> #include<math.h> #include<set> #include<map> #include<vector> #include<queue> #include…
A. Ability Draft 记忆化搜索. #include<stdio.h> #include<iostream> #include<string.h> #include<string> #include<ctype.h> #include<math.h> #include<set> #include<map> #include<vector> #include<queue> #i…
A. Donut 扫描线+线段树. #include<cstdio> #include<algorithm> using namespace std; typedef long long ll; const int N=800010,M=2222222; int n,m,cnt,i,j;ll L,R,D,a[N]; int tag[M],v[M],ans; struct E{ ll x,l,r;int s; E(){} E(ll _x,ll _l,ll _r,int _s){x=_…
A. Three Arrays 枚举每个$a_i$,双指针出$b$和$c$的范围,对于$b$中每个预先双指针出$c$的范围,那么对于每个$b$,在对应$c$的区间加$1$,在$a$处区间求和即可. 树状数组维护,时间复杂度$O(n\log n)$. #include<stdio.h> #include<iostream> #include<string.h> #include<string> #include<ctype.h> #include&…