結果
| 問題 |
No.1444 !Andd
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-23 15:36:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 160 ms / 2,000 ms |
| コード長 | 746 bytes |
| コンパイル時間 | 2,459 ms |
| コンパイル使用メモリ | 191,548 KB |
| 最終ジャッジ日時 | 2025-01-18 07:31:13 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:13:43: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
constexpr int kN = int(2E4 + 10);
constexpr int kC = 1 << 10;
int a[kN];
bool now[kN][kC], dp[kN][kC];
int main() {
int n, ans = 1;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
now[0][1] = true;
for (int i = 1; i <= n; i++) {
if (a[i] == 0) {
while (i++ <= n) printf("1\n");
break;
}
for (int j = 0; j < kC; j++) if (now[i - 1][j]) dp[i][j & a[i]] = true;
for (int j = 0; j < kC; j++) if (dp[i][j]) ans++;
if (now[i - 1][1] && dp[i][a[i]]) ans--;
if (dp[i - 1][0]) ans--;
for (int j = 0; j < kC; j++) if (now[i - 1][j]) now[i][(j * a[i]) & (kC - 1)] = true;
for (int j = 0; j < kC; j++) if (dp[i][j]) now[i][j] = true;
printf("%d\n", ans);
}
}