結果
問題 | No.1444 !Andd |
ユーザー |
|
提出日時 | 2021-01-22 15:00:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,022 bytes |
コンパイル時間 | 1,703 ms |
コンパイル使用メモリ | 196,368 KB |
最終ジャッジ日時 | 2025-01-18 03:18:45 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 5 RE * 15 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:14:43: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | for (int i = 1; i <= n; i++) scanf("%d", &a[i]); | ~~~~~^~~~~~~~~~~~~
ソースコード
// Compile flags -Wall -Wextra -Wshadow -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -fmax-errors=2 #include <bits/stdc++.h> using namespace std; constexpr int kN = int(5E3 + 10); constexpr int kC = 1 << 10; int a[kN], cnt[kN]; bitset<kC> dp[kN], now; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); now[0] = true; cnt[0] = 1; for (int i = 1; i <= n; i++) { //for (int j = 0; j < kC; j++) if (dp[i - 1][j]) dp[i][(j + a[i]) & 1023] = true; for (int j = 0; j < kC; j++) if (now.test(j)) dp[i][j & a[i]] = true; cnt[i] = cnt[i - 1] + dp[i].count(); if (now.test(0) && dp[i].test(a[i])) cnt[i]--; //printf("cnt[%d] = %d\n", i, cnt[i]); //for (int j = 0; j < kC; j++) printf("%d", now[j] ? 1 : 0); //printf("\n"); //for (int j = 0; j < kC; j++) printf("%d", dp[i][j] ? 1 : 0); //printf("\n"); now = (now << a[i]) | (now >> (kC - a[i])) | dp[i]; } printf("%d\n", cnt[n]); // X & A + B -> ge B // X + A & B -> le B // dp[i][j] : lst and at i, possible values }