CF-Codeforces Round #487 (Div. 2)-A-A Blend of Springtime
描述
题解
判定连续的三个字母是否同时包含 ABC A B C ,不要求 ABC A B C 的顺序。
代码
#include <iostream>
#include <string>
using namespace std;
const string str[] = {
"ABC", "ACB", "BAC", "BCA", "CAB", "CBA"};
string s;
int main(int argc, const char * argv[])
{
cin >> s;
bool flag = false;
for (int i = 0; i < s.length(); i++)
{
for (int j = 0; j < 6; j++)
{
int cnt = 0;
for (int k = 0; k < 3; k++)
{
if (s[i + k] == str[j][k])
{
cnt++;
}
}
if (cnt == 3)
{
flag = true;
break;
}
}
}
if (flag)
{
cout << "Yes\n";
}
else
{
cout << "No\n";
}
return 0;
}