結果

問題 No.2240 WAC
ユーザー _yurimoir
提出日時 2023-03-11 08:43:49
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 700 bytes
コンパイル時間 2,777 ms
コンパイル使用メモリ 244,520 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-18 06:14:44
合計ジャッジ時間 3,905 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    string s;
    cin >> n >> m >> s;
    int len = 2 * (n + m);
    int w_cnt = 0;
    for(int i = 0; i < len; i++){
        if(s[i] == 'W'){
            w_cnt++;
        }else if(s[i] == 'A'){
            w_cnt = max(w_cnt - 1, 0);
        }
    }
    if(w_cnt > 0){
        cout << "No" << endl;
        return 0;
    }
    int c_cnt = 0;
    for(int i = len - 1; i >= 0; i--){
        if(s[i] == 'C'){
            c_cnt++;
        }else if(s[i] == 'A'){
            c_cnt = max(c_cnt - 1, 0);
        }
    }
    if(c_cnt > 0){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}
0