結果
問題 |
No.183 たのしい排他的論理和(EASY)
|
ユーザー |
|
提出日時 | 2018-12-31 11:42:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 152 ms / 5,000 ms |
コード長 | 736 bytes |
コンパイル時間 | 556 ms |
コンパイル使用メモリ | 62,776 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-01 06:18:47 |
合計ジャッジ時間 | 2,418 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:28:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 28 | scanf("%d", &A[i]); | ~~~~~^~~~~~~~~~~~~ main.cpp:38:18: warning: iteration 65536 invokes undefined behavior [-Waggressive-loop-optimizations] 38 | ans += dp[i]; | ~~~~^ main.cpp:16:30: note: within this loop 16 | #define rep(i,b) for(ll i=0;i<(b);++i) | ^ main.cpp:37:4: note: in expansion of macro ‘rep’ 37 | rep(i, (1 << 16)+1) { | ^~~
ソースコード
#include <iostream> #include <string> #include <set> #include <map> #include <vector> #include <numeric> #include <tuple> #include <cstdio> #include <assert.h> using namespace std; typedef long long ll; #define rep(i,b) for(ll i=0;i<(b);++i) #define rep1(i,b) for(ll i=1;i<=(b);++i) #define vec vector #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl; int N; int A[5010]; int dp[(1 << 16)]; int main() { cin >> N; rep1(i, N) { scanf("%d", &A[i]); dp[A[i]] = 1; } for (int i=0;i<=N;i++) { for (int j=(1 << 15);j>=0;j--) { dp[j ^ A[i]] |= dp[j] & dp[A[i]]; } } int ans = 0; rep(i, (1 << 16)+1) { ans += dp[i]; } cout << ans << endl; }