---
# System prepended metadata

title: j244. 111北二3a.兌獎問題
tags: [資訊學科]

---

link：https://zerojudge.tw/ShowProblem?problemid=j244
* 暴力
```C++=
#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int k,n;
    cin>>k>>n;
    string str;
    vector<vector<string>> table(3);
    for (int i=0;i<3;i++){
        cin>>str;
        table[i].push_back(str);
        table[i].push_back(str.substr(2,k-2));
        table[i].push_back(str.substr(3,k-3));
        table[i].push_back(str.substr(4,k-4));
        table[i].push_back(str.substr(k-3,3));
        
        table[i].push_back(str.substr(1,k-1));
    }
    
    long long int ans=0;
    int final;
    string inp;
    for (int i=0;i<n;i++){
        cin>>inp;
        final = 0;
        for (int j=0;j<3;j++){
            if (inp == table[j][0]) final = max(final,500000);
            else if (inp.substr(2,k-2) == table[j][1] ) final = max(final,10000);
            else if (inp.substr(4,k-4)==table[j][3] ) final = max(final,1000);
            else if (inp.substr(k-3,3) == table[j][4]) final = max(final,300);
            else continue;

        }
        ans += final;
    }
    cout<<ans<<"\n";
    
    /*for (auto i:table){
        for (auto j:i) cout<<j<<" ";
        cout<<endl;
    }*/
}
```