document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include<cstdio>
  2. const int SIZE = 1<<20;
  3. int dp[SIZE],a[SIZE];
  4. int main(){
  5.     int n,q;
  6.     scanf("%d%d",&n,&q);
  7.     for(int i=0;i<n;i++){
  8.         char s[24];
  9.         scanf("%s",s);
  10.         for(int j=0;j<20;j++)a[i]|=(int)(s[j]-\'0\')<<j;
  11.         dp[a[i]]++;
  12.     }
  13.     for(int i=0;i<20;i++)
  14.         for(int j=0;j<SIZE;j++)
  15.             if((j>>i)&1)dp[j^(1<<i)]+=dp[j];
  16.     while(q--){
  17.         long long an=0;
  18.         int x=0;
  19.         char s[24];
  20.         scanf("%s",s);
  21.         for(int j=0;j<20;j++)x|=(int)(s[j]-\'0\')<<j;
  22.         for(int i=0;i<n;i++){
  23.             an+=dp[x^(x&a[i])];
  24.             if((x&a[i])==x)an--;
  25.         }
  26.         printf("%I64d\\n",an/2);
  27.     }
  28. }
');