1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <bits/stdc++.h>

using namespace std;

bool a[4][1000];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	int n;
	cin >> n;
	string s1,s2,s3;
	int r1,r2,r3;
	cin >> r1 >> s1;
	cin >> r2 >> s2;
	cin >> r3 >> s3;
	for(int i = 0; i < n; i++){
		if(s1[i] == '1')
			a[1][i] = 1;
		if(s2[i] == '1')
			a[2][i] = 1;
		if(s3[i] == '1')
			a[3][i] = 1;
	}
	int ans = 0;
	for(int i = 0; i <= (1 << n) - 1; i++){
		int ile1=0;
		int ile2=0;
		int ile3=0;
		for(int j = 0; j < n; j++){
			bool x;
			if(((1 << j) & i) != 0)
				x = 1;
			else
				x = 0;
			ile1 += a[1][j] ^ x;
			ile2 += a[2][j] ^ x;
			ile3 += a[3][j] ^ x;
		}
		if(ile1 <= r1 || ile2 <= r2 || ile3 <= r3)
			ans++;
	}
	cout << ans;
	
	
	return 0;
}