公式

A - 財布の中身 / Contents of the Wallet 解説 by kyopro_friends


問題文の指示通り、「『\(S\) に B が含まれている』かつ『\(S\) に C が含まれている』」を満たすかを調べればよいです。

実装例 (C++)

#include<bits/stdc++.h>
using namespace std;

int main(){
  int n;
  string s;
  cin >> n >> s;
  if(s.find('B')!=-1 && s.find('C')!=-1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

実装例 (Python)

N = int(input())
S = input()
if ("C" in S) and ("B" in S):
  print("Yes")
else:
  print("No")