Test instructions: Enter five lengths of 100 01 strings, choose from each string is a 1 position, any two string selection of the location can not be the same, the total number of cases, the answer is multiplied by the constant 531192758 and then the 1e9+7 modulo.
If the DFS complexity for the five strings is 10^10 steady T, then the contribution of the last string to the first four strings of Dfs is added directly to the final answer. The DFS parameters are the first X string and the fifth string where the sum of 1 is not selected.
The code is as follows
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <
String> #include <queue> using namespace std;
typedef pair<int,int>pp;
const int mod = 1E9+7;
Char he[5][105];
int vis[105];
Long long ans;
void solve (int x,int sum) {if (x = = 4) {ans = (ans + sum)%mod;
return; } for (int i = 0; i < i++) {if (he[x][i] = = ' 1 ' &&!vis[i]) {Vis[i] =
1;
if (he[4][i] = = ' 1 ') solve (x+1,sum-1);
else solve (x+1,sum);
Vis[i] = 0;
}}} int main () {while (scanf ("%s", he[0])! = EOF) {for (int i = 1; i < 5; i++) scanf ("%s", He[i]);
int su = 0;
for (int i = 0; i < i++) {if (he[4][i] = = ' 1 ') Su + +;
} ans = 0;
memset (vis,0,sizeof (VIS));
Solve (0,SU);
Ans = ans * 531192758%mod;
printf ("%lld\n", ans);
}
}