結果

問題 No.2240 WAC
ユーザー GlinTFrauleinGlinTFraulein
提出日時 2023-03-10 23:11:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 1,071 bytes
コンパイル時間 5,610 ms
コンパイル使用メモリ 265,412 KB
実行使用メモリ 5,436 KB
最終ジャッジ日時 2023-10-18 08:54:25
合計ジャッジ時間 5,829 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 13 ms
5,436 KB
testcase_11 AC 13 ms
4,644 KB
testcase_12 AC 11 ms
4,348 KB
testcase_13 AC 5 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 7 ms
4,348 KB
testcase_16 AC 13 ms
4,644 KB
testcase_17 AC 7 ms
4,348 KB
testcase_18 AC 4 ms
4,348 KB
testcase_19 AC 6 ms
4,348 KB
testcase_20 AC 8 ms
4,348 KB
testcase_21 AC 7 ms
4,348 KB
testcase_22 AC 8 ms
4,464 KB
testcase_23 AC 6 ms
4,348 KB
testcase_24 AC 11 ms
4,348 KB
testcase_25 AC 12 ms
4,348 KB
testcase_26 AC 4 ms
4,348 KB
testcase_27 AC 3 ms
4,348 KB
testcase_28 AC 6 ms
4,348 KB
testcase_29 AC 3 ms
4,348 KB
testcase_30 AC 6 ms
4,348 KB
testcase_31 AC 9 ms
4,348 KB
testcase_32 AC 4 ms
4,348 KB
testcase_33 AC 6 ms
4,348 KB
testcase_34 AC 7 ms
4,348 KB
testcase_35 AC 3 ms
4,348 KB
testcase_36 AC 11 ms
4,348 KB
testcase_37 AC 9 ms
4,348 KB
testcase_38 AC 6 ms
4,348 KB
testcase_39 AC 13 ms
4,644 KB
testcase_40 AC 6 ms
4,348 KB
testcase_41 AC 10 ms
4,556 KB
testcase_42 AC 9 ms
4,560 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:47:25: warning: ignoring return value of 'std::vector<bool, _Alloc>::reference std::vector<bool, _Alloc>::operator[](size_type) [with _Alloc = std::allocator<bool>; reference = std::vector<bool>::reference; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   47 |         used[posa.back()];
      |                         ^
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/vector:65,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/functional:62,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:71,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_bvector.h:1035:7: note: declared here
 1035 |       operator[](size_type __n)
      |       ^~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
 
#define elif else if
#define ll long long
#define vll vector<long long>
#define vec vector
#define embk emplace_back
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep3(i, n, k) for (int i = k; i < n; i++)
#define all(a) a.begin(), a.end()
 
using namespace std;
using namespace atcoder;
const ll INF = 1LL << 60;
const ll mod = 998244353;

int main() {
  ll n, m; cin >> n >> m;
  string s; cin >> s;
  ll ss = s.size();
  
  vec<bool> used(ss);
  deque<ll> posa;
  ll count = 0;
  rep(i, ss) {
    if (s[ss-i-1] == 'A') {
      count++;
      posa.push_back(ss-i-1);
    }
    elif (s[ss-i-1] == 'W') {
      count--;
      if (count < 0) {
        cout << "No" << endl;
        return 0;
      }
      used[posa.front()] = 1;
      posa.pop_front();
      

    }
  }
    
  rep(i, ss) {
    if (s[i] == 'C') {
      if (posa.back() < i) {
        used[posa.back()];
        posa.pop_back();
      }
      else {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  
  cout << "Yes" << endl;
  
}
0