結果
問題 |
No.2629 A replace B replace C
|
ユーザー |
![]() |
提出日時 | 2024-02-16 21:49:27 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 919 bytes |
コンパイル時間 | 4,484 ms |
コンパイル使用メモリ | 308,660 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-09-28 20:04:13 |
合計ジャッジ時間 | 6,266 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 58 WA * 3 |
ソースコード
#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; } if (ab == 1 && bc == 1 && ac == 1) { cout << "No" << endl; return 0; } if (ab == bc && ac <= ab + bc) { cout << "Yes" << endl; } else { cout << "No" << endl; } }