結果

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

ソースコード

diff #

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

/*main*/
int main() {
  int n,m; cin >> n >> m;
  string s; cin >> s;
  int count=0;
  for(int i=0;i<s.length();i++){
    if(s.at(i)=='W') count++;
    else if(s.at(i)=='A' && count>0) count--;
  }
  if(count){
    cout << "No" << endl;
    return 0;
  }
  for(int i=s.length()-1;i>=0;i--){
    if(s.at(i)=='C') count++;
    else if(s.at(i)=='A' && count>0) count--;
  }
  if(count){
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;

  return 0;
}
0