結果
| 問題 | No.2629 A replace B replace C | 
| コンテスト | |
| ユーザー |  a01sa01to | 
| 提出日時 | 2025-05-06 00:37:32 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 4 ms / 2,000 ms | 
| コード長 | 714 bytes | 
| コンパイル時間 | 3,607 ms | 
| コンパイル使用メモリ | 273,980 KB | 
| 実行使用メモリ | 7,844 KB | 
| 最終ジャッジ日時 | 2025-05-06 00:37:40 | 
| 合計ジャッジ時間 | 7,450 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 61 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  string s, t;
  cin >> n >> s >> t;
  bool ok = true;
  int ab = 0, ac = 0, bc = 0;
  rep(i, n) {
    if (s[i] == t[i]) continue;
    if (s[i] > t[i]) ok = false;
    if (s[i] == 'A' && t[i] == 'B') ab++;
    if (s[i] == 'A' && t[i] == 'C') ac++;
    if (s[i] == 'B' && t[i] == 'C') bc++;
  }
  if (ab != bc) ok = false;
  if (ac > 0 && bc == 0) ok = false;
  cout << (ok ? "Yes" : "No") << '\n';
  return 0;
}
            
            
            
        