The source of this question is MU conjecture in the AI field. I also referred to the relevant materials during the competition, but in the end I barely introduced the rule.
Note the following attributes. First, how to change M in MI is always the first place. Second, because the conversion can only be performed between I and U, except the first one is M. If there are strings not U or I, the conversion will never be possible. Third, U can be regarded as three I, whether I is first converted to U and then converted to a certain number of I, and then converted to a certain number of U, therefore, you can use I as the general equivalence to exchange all the letters.
# Include <iostream> # include <cstring> # include <string> using namespace std; int main () {int testcase; cin> testcase; while (testcase --) {string p = "MI"; int counti = 1, countu = 0, counti2 = 0, countu2 = 0, cm = 0, pos = 0; string tar; cin> tar; for (int I = 0; I <tar. length (); I ++) {if (tar [I] = 'M') {cm ++;} if (tar [I] = 'I ') {counti2 ++;} if (tar [I] = 'U') {countu2 ++ ;}} if (cm = 1 & tar [0] = 'M' & (countu2*3 + counti2) % 2 = 0 & (countu2*3 + counti2 ) % 3! = 0) | (countu2*3 + counti2) = 1) {pos = 1;} else {pos = 0;} if (pos = 0) {cout <"No" <endl;} else if (pos = 1) cout <"Yes" <endl;} return 0 ;}