5 friends play LOL together . Every one should BAN one character and PICK one character . The enemy should BAN 55 characters and PICK 55 characters . All these 2020 heroes must be different .
Every one can BAN any heroes by his personal washes . But he can only PICK heroes which he has bought .
Suppose the enemy can PICK or BAN any heroes. How many different ways are there satisfying the conditions?
For example , a valid way is :
Player 11 : picks hero 11, bans hero 22
Player 22 : picks hero 33, bans hero 44
Player 33 : picks hero 5, bans hero 66
Player 44 : picks hero 77, bans hero 88
Player 55 : picks hero 99, bans hero 1010
Enemies pick heroes 11,12,13,14,1511,12,13,14,15 , ban heroes 16,17,18,19,2016,17,18,19,20 .
Input
The input contains multiple test cases.(No more than 2020)
In each test case . there’s 55 strings S[1] \sim S[5]S[1]∼S[5] ,respectively whose lengths are 100100 , For the ii-th person if he has bought the jj-th hero, the jj-th character of S[i]S[i] is '11', or '00' if not. The total number of heroes is exactly 100100 .
Output
For each test case , print the answer mod 10000000071000000007 in a single line .
样例输入
0110011100011001001100011110001110001110001010010111111110101010010011010000110100011001001111101011 1000111101111110110100001101001101010001111001001011110001111110101000011101000001011100001001011010 0100101100011110011100110110011100111100010010011001111110101111111000000110001110000110001100001110 1110010101010001000110100011101010001010000110001111111110101010000000001111001110110101110000010011 1000010011111110001101100000101001110100011000111010011111110110111010011111010110101111011111011011
样例输出
515649254
题目来源
ac code:
#include<algorithm>
#include<stdio.h>
#include<map>
using namespace std;
int MAP[110],MAPP[110],MAPPP[110];
char a[10][110];
#include<string.h>
typedef long long ll;
const int mod =1e9+7;
int main()
{
while(scanf("%s",a[0]+1)!=EOF)
{
for(int i=1; i<5; i++)
{
scanf("%s",a[i]+1);
}
memset(MAP,0,sizeof(MAP));
memset(MAPP,0,sizeof(MAPP));
memset(MAPPP,0,sizeof(MAPPP));
ll ans=0,anss=0;
for(int i=1; i<=100; i++)
{
if(a[3][i]=='1')
MAP[i]=1,ans++;
}
ll q=0;
for(int i=1; i<=100; i++)
{
if(a[4][i]=='1')
MAPP[i]=1,anss++;
MAPPP[i]=MAPP[i]*MAP[i];
if(MAPPP[i])
q++;
}
ll summ=ans*anss;
ll ss=0;
for(int i=1; i<=100; i++)
for(int j=1; j<=100; j++)
for(int k=1; k<=100; k++)
{
if(i==j||j==k||i==k)
continue;
if(a[0][i]=='0'||a[1][j]=='0'||a[2][k]=='0')
continue;
ll sum=0;
ll rr=MAP[i]+MAP[j]+MAP[k];
ll rrr=MAPP[i]+MAPP[j]+MAPP[k];
sum+=MAP[i]*(anss-rrr)+MAP[j]*(anss-rrr)+MAP[k]*(anss-rrr);
sum+=MAPP[i]*(ans-rr)+MAPP[j]*(ans-rr)+MAPP[k]*(ans-rr);
sum+=rr*rrr;
ss+=summ-sum-(q-(MAPPP[i]+MAPPP[j]+MAPPP[k]));
if(ss>=mod)
ss-=mod;
}
printf("%lld\n",ss%mod*531192758%mod);
}
}
/*
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111
*/