Chủ Nhật, 5 tháng 12, 2021

2021 HSG9 DANANG B2. DAIDIEN Từ đại diện

#include <bits/stdc++.h>
using namespace std;

const int N = 1e7 + 5;
vector <string> S;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    freopen("daidien.inp","r",stdin);
    freopen("daidien.out","w",stdout);

    while (1){
        string ts;
        cin >> ts;
        if (ts == "") break;
        S.push_back(ts);
    }

    string P = S.back();
    S.pop_back();

    int ans = 0;
    for (string s : S){
        if (s.size() != P.size()) continue;

        bool ok = true;
        for (int i = 0; i < P.size(); i++){
            if (P[i] == '?') continue;
            if (P[i] != s[i]) ok = false;
        }
        
        ans += ok;
    }

    cout << ans;
}

Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.