結果

問題 No.2240 WAC
ユーザー zezero
提出日時 2023-03-10 22:30:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,122 bytes
コンパイル時間 2,631 ms
コンパイル使用メモリ 164,656 KB
最終ジャッジ日時 2025-02-11 08:42:17
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 33 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cstring>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)
const int INF = 1e9;

int main(){
  int n,m;
  cin >> n >> m;
  string s;
  cin >> s;
  int len = n+m+n+m;
  set<int> st;
  bool yes = true;
  for (int i = len-1; i >= 0;i--){
    //cout << i;
    //cout << " set:" << endl;
    //for (auto e:st){
    //  cout << e  << " "; 
    //}
    //cout << endl;
    if (s[i] == 'A'){
      st.insert(i);
    }
    else if (s[i] == 'W'){
      if (st.empty()){
        yes = false;
        break;
      }
      else{
        auto itr = st.rbegin();
        st.erase((*itr));
      }
    }
  }
  for (int i = 0; i < len;i++){
    if (s[i] == 'C'){
      if (st.empty()){
        yes = false;
        break;
      }
      else{
        st.erase(st.begin());
      }
    }
  }
  if (yes){
    cout << "Yes\n";
  }
  else{
    cout << "No\n";
  }
 


  return 0;
}
0