結果
問題 |
No.2629 A replace B replace C
|
ユーザー |
![]() |
提出日時 | 2024-02-29 11:00:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 774 bytes |
コンパイル時間 | 2,695 ms |
コンパイル使用メモリ | 192,148 KB |
最終ジャッジ日時 | 2025-02-19 21:58:15 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 61 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int n, ac=0, ab=0, bc=0; string s, t; cin >> n >> s >> t; for (int i=0; i<n; i++){ if (s[i] > t[i]){ cout << "No" << endl; return 0; } if (s[i] == 'A' && t[i] == 'C') ac++; if (s[i] == 'A' && t[i] == 'B') ab++; if (s[i] == 'B' && t[i] == 'C') bc++; } //BCを使ってACをBCにする。(BCが1つでもあればACを消せる) if (ac > 0 && bc == 0){ cout << "No" << endl; return 0; } //ABとBCを対消滅させる。(ABの数だけBCを減らす) cout << (ab == bc ? "Yes" : "No") << endl; return 0; }