結果
問題 | No.2240 WAC |
ユーザー |
|
提出日時 | 2023-03-10 23:11:39 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 801 bytes |
コンパイル時間 | 2,104 ms |
コンパイル使用メモリ | 191,420 KB |
最終ジャッジ日時 | 2025-02-11 09:12:35 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 43 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:16:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | scanf("%d%d", &n, &m); | ~~~~~^~~~~~~~~~~~~~~~ main.cpp:17:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | scanf("%s", s); | ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h>using namespace std;const int N = 400010;char s[N];bool used[N];int c[N];int w[N];int pref[N];int suf[N];int main(){int n, m;scanf("%d%d", &n, &m);scanf("%s", s);int all = n + n + m + m;for (int i = 0; i < all; i++){c[i] = (s[i] == 'C' ? 1 : 0) + (i > 0 ? c[i - 1] : 0);pref[i] = (s[i] == 'A' ? 1 : 0) + (i > 0 ? pref[i - 1] : 0);}for (int i = all - 1; i >= 0; i--){w[i] = (s[i] == 'W' ? 1 : 0) + (i + 1 < all ? w[i + 1] : 0);suf[i] = (s[i] == 'A' ? 1 : 0) + (i + 1 < all ? suf[i + 1] : 0);}bool ok = true;for (int i = 0; i < all; i++) ok &= pref[i] >= c[i] && suf[i] >= w[i];if (ok)printf("Yes\n");elseprintf("No\n");return 0;}