A 签到. C 源点向每个软件连边.把每个软件拆成对应版本数个点,每个软件向版本连边.把每个conflict也看成一个点.每个版本向它对应的conflict连边,conflict向汇点连边.没有在conflict里的版本直接向汇点连边.所有边的容量都是$1$,跑最大流即可.conflict的意思也就是这些点最多只能选一个,那么拆点并限制容量即可. D 把每个点跟它有限制的点加入一个set,加边时用并查集维护,然后启发式合并两个set就行了. E 签到. H 这一看到一定是二分啊.然后T了一整场.…
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. Pieces of Parentheses 将括号串排序,先处理会使左括号数增加的串,这里面先处理减少的值少的串:再处理会使左括号数减少的串,这里面先处理差值较大的串.确定顺序之后就可以DP了. 时间复杂度$O(n^3)$. #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N=310,inf=1000000; int n,i,j,m,all,…
题目: Problem D. Great AgainInput file: standard inputOutput file: standard outputTime limit: 2 secondsMemory limit: 512 megabytesThe election in Berland is coming. The party United Berland is going to use its influence to win themagain. The crucial co…
题目:Problem K. PiecemakingInput file: standard inputOutput file: standard outputTime limit: 1 secondMemory limit: 512 mebibytesThe civil war in Berland continues for five years already. The United Nation decided to end the bloodshed.Berland consists o…