A. Survival Route 留坑. B. Dispersed parentheses $f[i][j][k]$表示长度为$i$,未匹配的左括号数为$j$,最多的未匹配左括号数为$k$的方案数.时间复杂度$O(n^3)$. #include<cstdio> #include<algorithm> using namespace std; typedef long long ll; const int P=1000000009; const int N=310; int n,m
A. Drone With a Camera 三分套三分. #include<cstdio> #include<cmath> #include<algorithm> using namespace std; typedef long double ld; const ld K=1e9,inf=1e100,eps=1e-9; const int T=200; struct P{ ld x,y; P(){} P(ld _x,ld _y){x=_x,y=_y;} }O; st
A. Area of Effect 首先最优解中必有一个点在圆的边界上. 若半径就是$R$,则枚举一个点,然后把剩下的事件极角扫描即可,时间复杂度$O(m(n+m)\log(n+m))$. 否则圆必然撞到了两个圆,枚举一个点以及两个圆,二分出最大的半径,然后统计内部点数即可,时间复杂度$O(n^2m(n+m))$. #include<cstdio> #include<cmath> #include<algorithm> using namespace std; type
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]