/* Idiom correction
* Author: Guo fengzai
* Do not know whether it is correct or wrong. Please kindly advise
*/
# Include <cstdio>
# Include <string>
Using namespace STD;
Int main (){
Int n, m;
Scanf ("% d", & N, & M );
Char a [n] [400];
Char B [M + 1] [9];
For (INT I = 0; I <n; ++ I ){
Scanf ("% s", a [I]);
}
For (INT I = 1; I <m + 1; ++ I ){
Scanf ("% s", B [I]);
}
Scanf ("% s", B [0]); // The incorrect idiom is stored in B [0]
Char C [9];
For (INT I = 1; I <m + 1; ++ I ){
Strcpy (C, B [0]); // because B [0] cannot be modified, use C instead of B [0].
For (Int J = 0; j <8; j = J + 2 ){
If (B [0] [J]! = B [I] [J] | B [0] [J + 1]! = B [I] [J + 1]) {
C [J] = B [I] [J];
C [J + 1] = B [I] [J + 1];
If (strcmp (C, B [I]) = 0) {// if it is equal, search to see if it is in the same category
For (int K = 0; k <n; ++ K ){
Int length = strlen (A [k]);
Int b1 = 0, b2 = 0;
For (int l = 0; L <length; L = L + 2 ){
If (A [k] [l] = B [0] [J] & A [k] [L + 1] = B [0] [J + 1]) {
B1 = 1;
}
If (A [k] [l] = B [0] [J] & A [k] [L + 1] = B [0] [J + 1]) {
B2 = 1;
}
If (b1 = 1 & b2 = 1) {// output the Modification result in the same category and exit the program.
For (INT h = 0; H <8; H = H + 2 ){
Printf ("% C", B [I] [H], B [I] [H + 1]);
}
Return 0;
}
}
}
} Else {
Break; // if not equal, exit the current idiom comparison and enter the next comparison.
}
}
}
}
Return 0;
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.