A. Passage 枚举两个点,看看删掉之后剩下的图是否是二分图. #include <bits/stdc++.h> using namespace std ; const int MAXN = 205 ; vector < int > G[MAXN] ; int vis[MAXN] , col[MAXN] ; int n ; int dfs ( int u ) { for ( int i = 0 ; i < G[u].size () ; ++ i ) { int v =…
A. Associated Vertices 首先求出SCC然后缩点,第一次求出每个点能到的点集,第二次收集这些点集即可,用bitset加速,时间复杂度$O(\frac{nm}{64})$. #include<cstdio> #include<bitset> using namespace std; const int N=10010; int n,m,x,y,i,j,g[N],G[N],v[N*3],V[N*3],nxt[N*3],NXT[N*3],ed; int vis[N],…
A. (a, b)-Tower 当指数大于模数的时候用欧拉定理递归计算,否则直接暴力计算. #include<cstdio> #include<algorithm> #include<cmath> #include<string> #include<iostream> using namespace std; typedef long long LL; int pw(int x,int y,int mod){ int ret=1; for(int…
A. Avengers, The 留坑. B. Black Widow 将所有数的所有约数插入set,然后求mex. #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int>pi; const int mod=1e9+7; int n,i,x; set<int>T; inline void add(int n){ for(int i=1;i<=n…
A. Nanoassembly 首先用叉积判断是否在指定向量右侧,然后解出法线与给定直线的交点,再关于交点对称即可. #include<bits/stdc++.h> using namespace std; const int Maxn=300020; typedef long long LL; typedef pair<int,int>pi; struct P{ double x,y; P(){x=y=0;} P(double _x,double _y){x=_x,y=_y;}…
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; }…
n个服务器,k类任务,每个服务器完成一个任务都有特定的花费$cost_{i,j}$,但是你设置好某台机器去完成某项任务时他只能去完成这类任务,除非你可以花费$C$去更改配置.第$i$天要求去完成$q_{i,j}$个j类任务,问如何让总代价最小 用费用流去优化dp #include <bits/stdc++.h> using namespace std; #define rep(i, j, k) for (int i = int(j); i <= int(k); ++ i) #define…
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. 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. 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];…