我怎么没登出来
ExCh_dd2014_Gcdunk · · 题解
直接大力组合数显然是不可行的,此时,我们一般选择 dp。
考虑状压,设
剩余 BAN 和敌方情况显然为
考虑转移。初始
我们要使所有人 PICK 的不相同,看似很难。实则可以从小到大枚举每个英雄的编号,直接转移即可。注意转移要同时进行即要开一个临时数组以滚动。
时间复杂度
有任何问题可以私信。
::::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';
}
}