Official

B - Chord Editorial by en_translator


For beginners
  • If you are new to learning programming and do not know where to start, please try Problem A "Welcome to AtCoder" from practice contest. There you can find a sample code for each language.
  • Also, if you are not familiar with problems in programming contests, we recommend you to try some problems in "AtCoder Beginners Selection".
  • 競プロ典型 90 問」(Typical 90 Problems of Competitive Programming) is a collection of typical 90 competitive programming problems; unfortunately, currently the problem statements are all Japanese.


Following the given conditions, determine if \(S\) equals one of ACE, BDF, CEG, DFA, EGB, FAC, or GBD.
In fact, a length-three string \(S\) equals one of ACE, BDF, CEG, DFA, EGB, FAC, or GBD if and only if \(S\) is a substring of ACEGBDFAC, so one can also use this property to determine it.

Sample code

#include <iostream>
#include <string>
using namespace std;

int main() {
	string s;
	cin >> s;
	if (s == "ACE" or s == "BDF" or s == "CEG" or s == "DFA" or s == "EGB" or s == "FAC" or s == "GBD") cout << "Yes\n";
	else cout << "No\n";
}
#include <iostream>
#include <string>
using namespace std;

int main() {
	string s;
	cin >> s;
	string t = "ACEGBDFAC";
	cout << (t.find(s) == string::npos ? "No" : "Yes") << '\n';
}

posted:
last update: