A. Array Factory 将下标按前缀和排序,然后双指针,维护最大的右边界即可. #include<cstdio> #include<algorithm> using namespace std; typedef long long ll; const int N=200010; int n,i,j,anslen,ansl,ansr,mr,q[N]; ll a[N],lim; inline bool cmp(int x,int y){return a[x]<a[y];…
A. Artifact Guarding 选出的守卫需要满足$\max(a+b)\leq \sum a$,从小到大枚举每个值作为$\max(a+b)$,在权值线段树上找到最大的若干个$a$即可. 时间复杂度$O(n\log n)$. #include<cstdio> #include<algorithm> #include<set> #include<map> using namespace std; typedef long long ll; const…
A. Centroid Tree 枚举至多两个重心作为根,检查对于每个点是否都满足$2size[x]\leq size[father[x]]$即可. #include<stdio.h> #include<iostream> #include<string.h> #include<string> #include<ctype.h> #include<math.h> #include<set> #include<map&…
1. Ski race 枚举枚举倍数判断即可.时间复杂度$O(n\log m)$. #include<cstdio> #include<algorithm> using namespace std; int n,m,i,j,ans,flag,q[111111],a[111111]; bool v[11111111]; int main(){ freopen("input.txt","r",stdin); freopen("outpu…
A. Arithmetic Derivative 形如$p^p(p是质数)$的数的比值为$1$,用$k$个这种数相乘得到的数的比值为$k$,爆搜即可. #include<cstdio> #include<algorithm> typedef unsigned long long ll; int K,cnt,all;ll n,i,q[100000],ans[1000000]; ll po(ll a,ll b){ ll t=1; while(b--){ if(t>n/a)retu…
A. Bubbles 枚举两个点,求出垂直平分线与$x$轴的交点,答案=交点数+1. 时间复杂度$O(n^2\log n)$. #include<cstdio> #include<algorithm> #include<cmath> using namespace std; const double eps=1e-9; int sgn(double x){ if(x<-eps)return -1; if(x>eps)return 1; return 0; }…
A. Bracket Expression 直接按题意模拟即可. 时间复杂度$O(n)$. #include<stdio.h> #include<algorithm> #include<math.h> #include<string.h> #include<string> #include<vector> #include<set> #include<map> #include<queue> #in…
A. Graph Coloring 答案为$1$很好判,为$2$只需要二分图染色,对于$3$,首先爆搜哪些边要染成第$3$种颜色,然后二分图染色判定即可. B. Decimal Fraction 枚举前缀,那么只需要求出后面部分的最小循环节即可,将串翻转之后进行KMP,循环节长度$=i-next[i]$. 时间复杂度$O(n)$. C. Teams of Equal Power 首先将球员按能力值从大到小排序,假设一队的队长能力值比二队队长高,那么显然一队队长只能是第一个人,枚举二队队长,然后看…
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. Apple 按题意模拟即可. #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…