模拟题,易知将所有U换成I,补全所有删去的U,应为2的幂,又因为每次删去2个U,即6个I,所以对6取模,发现余数只有2和4,所以如果余数为2,4则必为yes。
注意开头不为M和中间有M的情况
/*
author:jxy
lang:C/C++
university:China,Xidian University
**If you need to reprint,please indicate the source**
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#define INF 1E9
using namespace std;
int main()
{
int T;
char s[1000005];
scanf("%d",&T);
while(T--)
{
scanf("%s",s);
int i,j=0,len=strlen(s);
if(s[0]=='M')
for(i=1,j=0;i<len;i++)
{
if(s[i]=='U')
j+=3;
else if(s[i]=='I')j++;
else {j=0;break;}
}
printf("%s\n",j%6!=2&&j%6!=4&&j!=1?"No":"Yes");
}
}