//legal word dictionary string dictionary = “xX0123456789abcdefABCDEF”;
bool judge_indictionary(string input_str) { for (int i = 0; i < input_str.size(); i++) { if (dictionary.find(input_str[i]) == -1) { return false; } } return true; }
int main() {
string key_word;
while (cin >> key_word)
{
string temp;
vector
int index_f = 0;
int index_b = 0;
while (cin >> temp)
{
//pick usefull information
index_f = 0;
index_b = temp.find_first_of('[');
vec_word.push_back(temp.substr(0, index_b));
index_f = temp.find_first_of('=');
index_b = temp.find_first_of(',');
vec_addr.push_back(temp.substr(index_f + 1, (index_b - index_f - 1)));
temp.erase(index_f, (index_b - index_f + 1));
index_f = temp.find_first_of('=');
index_b = temp.find_first_of(',');
vec_mask.push_back(temp.substr(index_f + 1, (index_b - index_f - 1)));
temp.erase(index_f, (index_b - index_f + 1));
index_f = temp.find_first_of('=');
index_b = temp.find_first_of(']');
vec_val.push_back(temp.substr(index_f + 1, (index_b - index_f - 1)));
}
//the flag of having a result or not
int flag = 0;
for (int i = 0; i < vec_word.size(); i++)
{
if (vec_word[i] == key_word
&&(vec_addr[i].substr(0,2)=="0x"|| vec_addr[i].substr(0, 2) == "0X")
&&(vec_mask[i].substr(0, 2) == "0x" || vec_mask[i].substr(0, 2) == "0X")
&&(vec_val[i].substr(0, 2) == "0x" || vec_val[i].substr(0, 2) == "0X")
&& judge_indictionary(vec_addr[i])
&& judge_indictionary(vec_mask[i])
&& judge_indictionary(vec_val[i]))
{
flag = 1;
cout << vec_addr[i];
cout << " ";
cout << vec_mask[i];
cout << " ";
cout << vec_val[i];
cout << endl;
}
}
//if doesn't find right information
if (flag==0)
cout << "FAIL" << endl;
}
} ```