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