結果

問題 No.2240 WAC
コンテスト
ユーザー Muhammad Ashar Usmani
提出日時 2025-11-17 13:47:39
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,217 bytes
コンパイル時間 1,633 ms
コンパイル使用メモリ 198,864 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2025-11-17 13:47:43
合計ジャッジ時間 3,320 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    long long N, M;
    string S;
    cin >> N >> M >> S;

    long long needWA = N, needAC = M;
    deque<int> W_queue; // positions of unpaired W for WA
    deque<int> A_queue; // positions of unpaired A for AC

    for (char ch : S) {
        if (ch == 'W') {
            W_queue.push_back(1); // we only care about count, position not needed
        } else if (ch == 'A') {
            if (needWA > 0 && !W_queue.empty()) {
                // pair earliest W with this A to form WA
                needWA--;
                W_queue.pop_front();
            } else {
                // keep this A for future AC
                A_queue.push_back(1);
            }
        } else if (ch == 'C') {
            if (needAC > 0 && !A_queue.empty()) {
                // pair earliest available A with this C to form AC
                needAC--;
                A_queue.pop_front();
            } else {
                cout << "No\n";
                return 0;
            }
        }
    }

    if (needWA == 0 && needAC == 0)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}
0