結果
問題 | No.2629 A replace B replace C |
ユーザー |
![]() |
提出日時 | 2024-02-16 21:58:01 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 868 bytes |
コンパイル時間 | 5,238 ms |
コンパイル使用メモリ | 307,916 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-09-28 20:14:43 |
合計ジャッジ時間 | 6,976 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 61 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>#define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)using namespace std;using namespace atcoder;typedef long long ll;int main() {int n;string s, t;cin >> n >> s >> t;int ab = 0, bc = 0, ac = 0;rep(i, 0, n) {if (s[i] == t[i]) continue;if (s[i] == 'A' && t[i] == 'B')ab++;else if (s[i] == 'B' && t[i] == 'C')bc++;else if (s[i] == 'A' && t[i] == 'C')ac++;else {cout << "No" << endl;return 0;}}int ad = ab + bc + ac * 2;if (ad % 2) {cout << "No" << endl;return 0;}bool ok = true;if (ac && bc == 0) ok = false;if (ab == bc && ok) {cout << "Yes" << endl;} else {cout << "No" << endl;}}