結果

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;

int n;
string s, t;
map<char, map<char, int>> mp;

int main() {
  cin >> n >> s >> t;
  for (int i = 0; i < n; i++) {
    mp[s[i]][t[i]]++;
  }
  if (mp['C']['A'] || mp['C']['B'] || mp['B']['A']) {
    cout << "No" << endl;
    return 0;
  }
  if (mp['A']['B'] != mp['B']['C']) {
    cout << "No" << endl;
    return 0;
  }
  if (mp['A']['C'] && !mp['B']['C']) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}
0