zoukankan      html  css  js  c++  java
  • AT2390 [AGC016F] Games on DAG

    题目链接

    显然我们只要求 (1,2) 号点的 SG 函数相同的情况数就可以了。

    考虑 SG 的运算 mex,其中 (0) 即为特殊。我们可以枚举 DAG 上的 (SG(x)=0) 的点是什么,这样的话这些点之间就不能连边,且其余的点中每个点都至少要向这些点连一条边。然后发现其余的点的连边情况是个子问题,于是直接DP即可。

    复杂度:(O(n3^n))

    inline ll calc1(int s, int t) {
    	ll res = 1;
    	for (int i = 0; i < n; ++i) if ((s >> i) & 1) {
    		res = 1ll * res * mi[ecnt[i][t]] % P;
    	}
    	return res;
    }
    inline ll calc2(int s, int t) {
    	ll res = 1;
    	for (int i = 0; i < n; ++i) if ((s >> i) & 1) {
    		res = 1ll * res * (mi[ecnt[i][t]] - 1) % P;
    	}
    	return res;
    }
    int f[NNN];
    inline void work() {
    	f[0] = 1;
    	for (int s = 1; s <= All; ++s) if ((s & 1) == ((s >> 1) & 1)) {
    		for (int t = s; t; t = (t - 1) & s) {
    			f[s] = (f[s] + 1ll * calc1(t, s ^ t) * calc2(s ^ t, t) % P * f[s ^ t] % P) % P;
    		}
    	}
    	ll ans = (mi[m] - f[All]) % P;
    	printf("%lld
    ", (ans % P + P) % P);
    }
    
  • 相关阅读:
    查看linux命令类型
    理解bashrc和profile[转载]
    问题:ldconfig
    箭头函数
    闭包函数
    方法
    手把手教你使用百度地图(图解)
    变量作用域与解构赋值
    iterable
    Map和Set
  • 原文地址:https://www.cnblogs.com/JiaZP/p/13704005.html
Copyright © 2011-2022 走看看