Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define F first
- #define S second
- #define pb push_back
- #define ll long long
- #define ld long double
- #define FILE "answer"
- #define pii pair <int,int>
- using namespace std;
- const int mod = 1e9 + 7;
- const int INF = 1e9;
- int bad[1005];
- string s, ss[10005];
- int f[1005][228];
- int cnt[228];
- int main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- //freopen("input.txt","r",stdin);
- //freopen("output.txt","w",stdout);
- int n;
- cin >> n;
- // string s;
- cin >> s;
- int kc = 0;
- for (int i=0; i<n; i++) {
- bad[s[i]] = 1;
- kc += s[i] == '*';
- }
- int m;
- cin >> m;
- for (int i=0; i<m; i++) {
- cin >> ss[i];
- }
- vector <string> good;
- int res = 0;
- for (int i=0; i<m; i++) {
- int f = 0;
- for (int j=0; j<n; j++) {
- if (bad[ss[i][j]] && s[j] == '*') {
- f = 1;
- break;
- }
- if (s[j] != '*' && ss[i][j] != s[j]){
- f = 1;
- break;
- }
- }
- if (!f) good.pb(ss[i]);
- }
- for (int i=0; i<good.size(); i++) {
- for (auto x : good[i]) {
- if (bad[x]) continue;
- if (!f[i][x]) cnt[x]++;
- f[i][x] = 1;
- }
- }
- for (int i=0; i<228; i++) {
- if (!bad[i]) res += cnt[i] == good.size();
- }
- cout << res << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement