📄 1797.cpp
字号:
#include <iostream>
#include <string>
using namespace std;
string str;
int main()
{
int test, i, flag;
cin >> test;
while (test--)
{
cin >> str;
i = 0;
while (str[i] == 'a')
{
i++;
}
if (i < 1)
{
cout << "NO" << endl;
continue;
}
if (str[i] != 'b' || str[i + 1] != 'a')
{
cout << "NO" << endl;
continue;
}
i += 2;
if (str[i] == 'b')
{
i++;
if (str[i] != 'd')
{
cout << "NO" << endl;
continue;
}
while (str[i] == 'd')
{
i++;
}
}
else
{
while (str[i] == 'd')
{
i++;
}
}
if (str[i] != 'h')
{
cout << "NO" << endl;
continue;
}
i++;
flag = 0;
for(;i < str.length();i++)
{
if (str[i] != 'f' && str[i] != 'k')
{
flag = 1;
cout << "NO" << endl;
break;
}
}
if (flag == 0)
{
cout << "YES" << endl;
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -