結果

問題 No.2240 WAC
ユーザー jiangly
提出日時 2023-03-11 00:11:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 801 bytes
コンパイル時間 1,696 ms
コンパイル使用メモリ 194,852 KB
最終ジャッジ日時 2025-02-11 09:25:10
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N, M;
    std::cin >> N >> M;
    
    std::string S;
    std::cin >> S;
    
    std::vector<int> pW, pA, pC;
    for (int i = 0; i < 2 * (N + M); i++) {
        if (S[i] == 'W') {
            pW.push_back(i);
        } else if (S[i] == 'A') {
            pA.push_back(i);
        } else {
            pC.push_back(i);
        }
    }
    
    for (int i = 0; i < N; i++) {
        if (pW[i] > pA[M + i]) {
            std::cout << "No\n";
            return 0;
        }
    }
    for (int i = 0; i < M; i++) {
        if (pA[i] > pC[i]) {
            std::cout << "No\n";
            return 0;
        }
    }
    std::cout << "Yes\n";
    
    return 0;
}
0