結果

問題 No.2629 A replace B replace C
ユーザー cho435
提出日時 2024-02-16 21:46:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 526 bytes
コンパイル時間 4,296 ms
コンパイル使用メモリ 251,508 KB
最終ジャッジ日時 2025-02-19 13:46:20
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using mint = atcoder::modint998244353;

int main(){
	int n;
	string s,t;
	cin>>n>>s>>t;
	int ca=0,cb=0,cd=0;
	rep(i,n){
		if(s.at(i)==t.at(i)) continue;
		else if(s.at(i)=='A'){
			if(t.at(i)=='B') ca++;
			else cd++;
		}else if(s.at(i)=='B'&&t.at(i)=='C') cb++;
		else{
			cout<<"No\n";
			return 0;
		}
	}
	if(cb>0) cd=0;
	if(ca==cb&&cd==0){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
}
0