結果

問題 No.2240 WAC
ユーザー yuyu_5510
提出日時 2023-03-10 21:54:51
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 876 bytes
コンパイル時間 1,558 ms
コンパイル使用メモリ 169,024 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-18 04:10:29
合計ジャッジ時間 2,632 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 42 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    int sn= (int)s.size();
    bool ok = true;
    vector<bool> used(sn);
    int wcnt = 0;
    int acnt = 0;

    for(int i = sn-1;i >= 0;--i){
        if(s[i] == 'W') ++wcnt;
        if(s[i] == 'A') ++acnt;
        if(acnt < wcnt){
            ok = false;
        }
    }

    for(int i = sn-1;i >= 0;--i){
        if(s[i] == 'A'){
            used[i] = true;
            --wcnt;
            if(wcnt == 0) break;
        }
    }

    acnt = 0;
    int ccnt = 0;
    for(int i = 0;i < n;++i){
        if(s[i] == 'A' && !used[i]) ++acnt;
        if(s[i] == 'C') ++ccnt;

        if(acnt < ccnt){
            ok = false;
        } 
    }

    if(ok){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}
0