考虑容斥,枚举哪些不存在的边选中了,剩下的不管,则可以用组合数计算方案数. 时间复杂度$O(m2^m+nm)$. #include<cstdio> const int N=550,B=10000,MAXL=350; int n,m,S,i,j,e[N][2],g[N],f[N]; inline int max(int a,int b){return a>b?a:b;} struct Num{ int a[MAXL],len,fu; Num(){len=1,fu=a[1]=0;} Num…
Time Limit:4000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Practice HDU 3833 Description Given a permutation P of 1 to N, YY wants to know whether there exists such three elements P[i1], P[i2], P[i3] that P[i1]-P[i2]…