結果
問題 | No.2240 WAC |
ユーザー |
|
提出日時 | 2023-03-10 21:51:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 1,047 bytes |
コンパイル時間 | 1,616 ms |
コンパイル使用メモリ | 170,832 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-18 04:08:17 |
合計ジャッジ時間 | 3,038 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 43 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {ios::sync_with_stdio(false);cin.tie(nullptr);int n, m;cin >> n >> m;string s;cin >> s;int cntW = 0, cntA = 0;vector<bool> used(2 * (n + m), true);for (int i = 2 * (n + m) - 1; i >= 0; i--) {if (s[i] == 'W') {cntW++;used[i] = false;if (cntW > cntA) {cout << "No" << '\n';return 0;}}if (s[i] == 'A') {cntA++;if (cntA <= n) {used[i] = false;}}}string t = "";for (int i = 0; i < 2 * (n + m); i++) {if (used[i]) {if (s[i] == 'A') {t += 'A';} else if (s[i] == 'C') {if (t.size() && t.back() == 'A') {t.pop_back();} else {t += 'C';}}}}cout << (t.size() ? "No" : "Yes") << '\n';}