結果
| 問題 |
No.2240 WAC
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-10 21:59:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,334 bytes |
| コンパイル時間 | 1,803 ms |
| コンパイル使用メモリ | 196,316 KB |
| 最終ジャッジ日時 | 2025-02-11 08:17:50 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 WA * 8 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d%d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:13:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%s", s);
| ~~~~~^~~~~~~~~
ソースコード
#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, a, c;
int all = n + n + m + m;
for (int i = 0; i < all; i++)
{
if (s[i] == 'W')
w.push_back(i);
else if (s[i] == 'A')
a.push_back(i);
else if (s[i] == 'C')
c.push_back(i);
}
bool ok = true;
for (int i = 0; i < all; i++)
{
if (used[i]) continue;
if (s[i] == 'C')
{
ok = false;
break;
}
if (s[i] == 'A')
{
if (c.empty() || c.front() <= i)
{
ok = false;
break;
}
used[c.front()] = true;
c.pop_front();
used[a.front()] = true;
a.pop_front();
}
else
{
if (a.empty() || a.back() <= i)
{
ok = false;
break;
}
used[w.front()] = true;
w.pop_front();
used[a.back()] = true;
a.pop_back();
}
}
ok &= w.empty() && a.empty() && c.empty();
if (ok)
printf("Yes\n");
else
printf("No\n");
return 0;
}