結果
| 問題 | No.2629 A replace B replace C | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-02-17 20:34:09 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 579 bytes | 
| コンパイル時間 | 1,976 ms | 
| コンパイル使用メモリ | 192,068 KB | 
| 最終ジャッジ日時 | 2025-02-19 15:38:43 | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 61 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ab = 0, bc = 0, S = 0;
    string s, t;
    cin >> n >> s >> t;
    for(int i = 0; i < n; i++){
        if(s[i] > t[i]){
            cout << "No\n";
            return 0;
        }
        if(s[i] == t[i]) continue;
        if(t[i] == 'C'){
        	S |= 1;
            bc++;
            if(s[i] == 'A') ab++;
        }else{
        	S |= 2;
            ab++;
        }
    }
    cout << (ab == bc && (ab == 0 || (ab >= 1 && S >= 3)) ? "Yes" : "No") << '\n';
}
            
            
            
        