結果

問題 No.2629 A replace B replace C
ユーザー kokosei
提出日時 2024-02-16 22:33:02
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 651 bytes
コンパイル時間 2,860 ms
コンパイル使用メモリ 245,440 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-09-28 21:08:47
合計ジャッジ時間 4,726 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 44 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int N;
string S, T;
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> N >> S >> T;
    bool f = true;
    for(int i = 0;i < N;i++){
        f &= (S[i] <= T[i]);
    }
    for(int i = 0, a = 0;i < N;i++){
        if(S[i] == T[i])continue;
        if(S[i] == 'A'){
            if(T[i] == 'C'){
                if(a-- == 0)f = false;
            }
            a += 1;
        }
        if(S[i] == 'B'){
            if(a-- == 0)f = false;
        }
        if(i == N - 1 && a != 0)f = false;
    }
    cout << (f ? "Yes\n" : "No\n");
    return 0;
}
0