結果

問題 No.2629 A replace B replace C
ユーザー Nzt3
提出日時 2024-02-17 00:10:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 553 bytes
コンパイル時間 1,694 ms
コンパイル使用メモリ 191,940 KB
最終ジャッジ日時 2025-02-19 15:11:41
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin>>N;
  string S,T;
  cin>>S>>T;
  int AC=0,AB=0,BC=0;
  for(int i=0;i<N;i++){
    if(S[i]>T[i]){
      cout<<"No\n";
      return 0;
    }
    if(S[i]!=T[i]){
      if(S[i]=='A'&&T[i]=='C'){
        AC+=1;
      }else if(S[i]=='A'&&T[i]=='B'){
        AB+=1;
      }else if(S[i]=='B'&&T[i]=='C'){
        BC+=1;
      }
    }
  }
  if(AB!=BC||BC==0&&AC!=0){
    cout<<"No\n";
  }else{
    cout<<"Yes\n";
  }

}
0