結果
| 問題 | No.2240 WAC |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-10 22:18:28 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,130 bytes |
| 記録 | |
| コンパイル時間 | 1,340 ms |
| コンパイル使用メモリ | 214,720 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-29 21:37:11 |
| 合計ジャッジ時間 | 2,970 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 WA * 5 RE * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int N = 400010;
char s[N];
bool used[N];
int main()
{
int n, m;
scanf("%d%d", &n, &m);
scanf("%s", s);
deque<int> w, c;
int all = n + n + m + m;
for (int i = 0; i < all; i++)
{
if (s[i] == 'W') w.push_back(i);
if (s[i] == 'C') c.push_back(i);
}
bool ok = true;
int i = 0, j = all - 1;
while (ok && i < j)
{
if (used[i])
{
i++;
continue;
}
if (used[j])
{
j--;
continue;
}
char left = s[i], right = s[j];
if (left == 'C' || right == 'W')
{
ok = false;
break;
}
if (left == 'A')
{
ok &= c.front() > i;
used[c.front()] = true;
c.pop_front();
}
if (right == 'A')
{
ok &= w.back() < j;
used[w.back()] = true;
w.pop_back();
}
i++;
j--;
}
if (ok)
printf("Yes\n");
else
printf("No\n");
return 0;
}