結果

問題 No.2240 WAC
ユーザー shoshoshomshoshoshom
提出日時 2023-03-10 23:11:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 801 bytes
コンパイル時間 2,120 ms
コンパイル使用メモリ 201,032 KB
実行使用メモリ 10,696 KB
最終ジャッジ日時 2023-10-18 08:54:41
合計ジャッジ時間 3,672 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
9,812 KB
testcase_01 AC 3 ms
9,812 KB
testcase_02 AC 4 ms
9,812 KB
testcase_03 AC 3 ms
9,812 KB
testcase_04 AC 3 ms
9,812 KB
testcase_05 AC 3 ms
9,812 KB
testcase_06 AC 3 ms
9,812 KB
testcase_07 AC 4 ms
9,812 KB
testcase_08 AC 3 ms
9,812 KB
testcase_09 AC 3 ms
9,812 KB
testcase_10 AC 8 ms
10,696 KB
testcase_11 AC 8 ms
10,696 KB
testcase_12 AC 8 ms
10,696 KB
testcase_13 AC 5 ms
10,340 KB
testcase_14 AC 4 ms
10,040 KB
testcase_15 AC 7 ms
10,568 KB
testcase_16 AC 7 ms
10,608 KB
testcase_17 AC 6 ms
10,516 KB
testcase_18 AC 5 ms
10,120 KB
testcase_19 AC 5 ms
10,204 KB
testcase_20 AC 8 ms
10,588 KB
testcase_21 AC 5 ms
10,428 KB
testcase_22 AC 6 ms
10,484 KB
testcase_23 AC 6 ms
10,340 KB
testcase_24 AC 6 ms
10,564 KB
testcase_25 AC 7 ms
10,552 KB
testcase_26 AC 4 ms
10,224 KB
testcase_27 AC 5 ms
10,108 KB
testcase_28 AC 5 ms
10,280 KB
testcase_29 AC 4 ms
9,976 KB
testcase_30 AC 6 ms
10,484 KB
testcase_31 AC 8 ms
10,648 KB
testcase_32 AC 4 ms
10,092 KB
testcase_33 AC 6 ms
10,500 KB
testcase_34 AC 6 ms
10,540 KB
testcase_35 AC 4 ms
9,940 KB
testcase_36 AC 7 ms
10,568 KB
testcase_37 AC 7 ms
10,616 KB
testcase_38 AC 5 ms
10,292 KB
testcase_39 AC 8 ms
10,660 KB
testcase_40 AC 5 ms
10,484 KB
testcase_41 AC 7 ms
10,544 KB
testcase_42 AC 7 ms
10,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const int N = 400010;
char s[N];
bool used[N];
int c[N];
int w[N];
int pref[N];
int suf[N];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    scanf("%s", s);
    int all = n + n + m + m;

    for (int i = 0; i < all; i++)
    {
        c[i] = (s[i] == 'C' ? 1 : 0) + (i > 0 ? c[i - 1] : 0);
        pref[i] = (s[i] == 'A' ? 1 : 0) + (i > 0 ? pref[i - 1] : 0);
    }
    for (int i = all - 1; i >= 0; i--)
    {
        w[i] = (s[i] == 'W' ? 1 : 0) + (i + 1 < all ? w[i + 1] : 0);
        suf[i] = (s[i] == 'A' ? 1 : 0) + (i + 1 < all ? suf[i + 1] : 0);
    }

    bool ok = true;

    for (int i = 0; i < all; i++) ok &= pref[i] >= c[i] && suf[i] >= w[i];

    if (ok)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}
0