Click Here to go back to the homepage.

Marko Solution:


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

char t9map[10][4] = {
    {0, 0, 0, 0},
    {'a', 'b', 'c', 0},
    {'d', 'e', 'f', 0},
    {'g', 'h', 'i', 0},
    {'j', 'k', 'l', 0},
    {'m', 'n', 'o', 0},
    {'p', 'q', 'r', 's'},
    {'t', 'u', 'v', 0},
    {'w', 'x', 'y', 'z'}
};

int main(){
    // #ifndef TESTING
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int dictionarySize;
    cin >> dictionarySize;
    string dictionary[dictionarySize];
    while(dictionarySize--){
        cin >> dictionary[dictionarySize];
    }
    string input;
    cin >> input;
    int inputLength = input.size();
    int count = 0;
    for(string s: dictionary){
        if(s.size() != inputLength){
            continue;
        }
        for(int i = 0; i < inputLength; i++){
            char c = s.at(i);
            int index = input.at(i) - '0' - 1;
            if(t9map[index][0] == c || t9map[index][1] == c || t9map[index][2] == c || t9map[index][3] == c){
                continue;
            }
            count--;
            break;
        }
        count++;
    }
    cout << count << endl;

    return 0;   
}