結果

問題 No.2629 A replace B replace C
ユーザー Yu_212
提出日時 2024-02-16 21:42:41
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 743 bytes
コンパイル時間 2,892 ms
コンパイル使用メモリ 244,736 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-09-28 19:57:00
合計ジャッジ時間 4,619 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    cin.tie(0)->sync_with_stdio(false);
    int n;
    string s, t;
    cin >> n >> s >> t;
    int a = 0;
    int b = 0;
    int c = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == t[i]) continue;
        if (s[i] == 'A' && t[i] == 'B') a++;
        else if (s[i] == 'B' && t[i] == 'C') b++;
        else if (s[i] == 'A' && t[i] == 'C') c++;
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    if (c > 0 && b == 0) {
        cout << "No" << endl;
        return 0;
    }
    if (a != b) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}
0