問題一覧 > 通常問題

No.2240 WAC

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 175
作問者 : noya2 / テスター : shobonvip 👑 Nachia
お気に入りにしたユーザー ProblemId : 9100 / 自分の提出
問題文最終更新日: 2023-03-10 21:28:20
WAC
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
yukicoder contest 380 (順位表) の他の問題:

Problem Statement

You are given a string $S$ consisting of $N$ Ws, $N+M$ As, and $M$ Cs.

Determine whether it is possible to obtain $N$ copies of WA and $M$ copies of AC by repeating the following operation $N+M$ times.

  • Choose integers $(i,j)$ satisfying $1\le i\lt j\le |S|$.
  • Obtain the string formed by concatenating $S_i$ and $S_j$ in this order.
  • Remove the $i$-th and $j$-th characters of $S$. (In particular, $|S|$ decreases by $2$.)
  • Constraints

    • $N,M$ are integers
    • $1\le N,M\le 10^5$
    • $S$ is a string consisting of $N$ Ws, $N+M$ As, and $M$ Cs

    Input

    $N$ $M$
    $S$
    

    Output

    If it is possible to obtain $N$ copies of WA and $M$ copies of AC by repeating the operation $N+M$ times, print Yes; otherwise, print No.

    Sample

    Sample 1
    Input
    1 2
    WAAACC
    Output
    Yes

    Choosing $(i,j)=(4,6)$ in the $1$st operation yields AC, choosing $(i,j)=(3,4)$ in the $2$nd operation yields AC, and choosing $(i,j)=(1,2)$ in the $3$rd operation yields WA.

    Sample 2
    Input
    2 2
    ACWAWACA
    Output
    Yes

    Sample 3
    Input
    2 3
    WACAACACAW
    Output
    No

    提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。