我怎么没登出来

· · 题解

直接大力组合数显然是不可行的,此时,我们一般选择 dp。

考虑状压,设 dp_i 为状态为 i 时的只考虑 PICK 的答案,这里的状态 i 是每个人是否决策完成,如 i=(10010)_2 时,dp_i 表第二个人和第五个人完成了决策的只考虑 PICK 的答案。

剩余 BAN 和敌方情况显然为 \text{A}_{95}^5\text{C}_{90}^5\text{C}_{85}^5。最终输出 dp_{2^5-1}\cdot \text{A}_{95}^5\text{C}_{90}^5\text{C}_{85}^5=dp_{31}\cdot \text{A}_{95}^5\text{C}_{90}^5\text{C}_{85}^5。

考虑转移。初始 dp_0=1。

我们要使所有人 PICK 的不相同,看似很难。实则可以从小到大枚举每个英雄的编号,直接转移即可。注意转移要同时进行即要开一个临时数组以滚动。

时间复杂度 \mathcal{O}(TH2^MM),其中 T=20,H=100,M=5。

有任何问题可以私信。

::::info[code]

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int cs = 531192758, mod = 1e9 + 7;
int dp[35], ndp[35];
signed main()
{
    string s[6];
    while(cin >> s[1] >> s[2] >> s[3] >> s[4] >> s[5])
    {
        memset(dp, 0, sizeof dp);
        memset(ndp, 0, sizeof ndp);
        dp[0] = 1;
        for(int i = 0; i <= 99; i++)
        {
            for(int j = 0; j <= 31; j++) ndp[j] = dp[j];
            for(int j = 0; j <= 31; j++)
            {
                for(int x = 0; x <= 4; x++)
                {
                    if((j >> x & 1) && s[x + 1][i] == '1')
                    {
                        ndp[j] = (ndp[j] + dp[j ^ (1 << x)]) % mod;
                    }
                }
            }
            for(int j = 0; j <= 31; j++) dp[j] = ndp[j];
        }
        cout << dp[31] * cs % mod << '\n';
    }
}