D - chess960 解説 by evima

楽な実装

文字列中に別の文字列が出現する位置を検索する標準ライブラリ(C++ の find, rfind など)を使えば、各文字の位置を手軽に求められます。

実装例(Python)

S = input()
c1 = (S.rfind('B') - S.find('B')) % 2 == 1
c2 = S.find('R') < S.find('K') < S.rfind('R')
print('Yes' if c1 and c2 else 'No')

投稿日時:
最終更新: