fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4.  
  5. int main() {
  6. int x, n, a[10], cnt, f[10];
  7. char s[60];
  8. f[0]=1;
  9. for(int i=1; i<7; i++) f[i]=f[i-1]*i;
  10. cnt=0;
  11. scanf("%d%d", &x, &n);
  12. while(n--) {
  13. for(int i=0; i<10; i++) a[i]=0;
  14. scanf("%s", s);
  15. for(int i=0; i<54; i++) {
  16. if(s[i]=='0') {
  17. if(i<36) a[i/4]++;
  18. else a[8-(i-36)/2]++;
  19. }
  20. }
  21. for(int i=0; i<9; i++) if(a[i]>=x) cnt+=f[a[i]]/f[x]/f[a[i]-x];
  22. }
  23. printf("%d", cnt);
  24. return 0;
  25. }
Success #stdin #stdout 0s 3344KB
stdin
1 3
100101110000001011000001111110010011110010010111000101
001010000000101111100000000000000111101010101111111010
011110011110000001010100101110001011111010001001111010
stdout
85