結果

問題 No.2240 WAC
ユーザー shoshoshom
提出日時 2023-03-10 23:45:11
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 944 bytes
コンパイル時間 1,584 ms
コンパイル使用メモリ 193,040 KB
最終ジャッジ日時 2025-02-11 09:22:14
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 43
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
main.cpp:15:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |     scanf("%s", s);
      |     ~~~~~^~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const int N = 400010;
char s[N];

int wa[N];
int ac[N];

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

    int* wi = wa;
    int* ai = ac;
    char* send = s + all;
    for (char* p = s; p != send; p++)
    {
        if (*p == 'W')
            *(wi++) = 1;
        else if (*p == 'C')
            *(ai++) = -1;
        else if (t == 0)
            *(wi++) = -1;
        else
        {
            *(ai++) = 1;
            t--;
        }
    }

    bool ok = true;

    int* end = ac + m * 2;
    int* p = ac;
    int sum = 0;
    for (; p != end; p++)
    {
        sum += *p;
        ok &= sum >= 0;
    }
    end = wa + n * 2;
    p = wa;
    sum = 0;
    for (; p != end; p++)
    {
        sum += *p;
        ok &= sum >= 0;
    }

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

    return 0;
}
0