結果
問題 | No.183 たのしい排他的論理和(EASY) |
ユーザー |
![]() |
提出日時 | 2017-06-28 14:46:16 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 222 ms / 5,000 ms |
コード長 | 1,037 bytes |
コンパイル時間 | 592 ms |
コンパイル使用メモリ | 72,104 KB |
実行使用メモリ | 163,592 KB |
最終ジャッジ日時 | 2024-06-30 01:31:23 |
合計ジャッジ時間 | 2,771 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:47:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 47 | scanf("%d", A+i); | ~~~~~^~~~~~~~~~~
ソースコード
#include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <string> #include <map> #include <bitset> #include <vector> #include <queue> typedef long long ll; #define fi first #define se second const ll mod = 1000000007; // 123456789 using namespace std; /////////////////////////////////////////////// //DP問題 //自力◎ /////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////// int N; int idx; int top = 0; int ans = 0; int A[5010]; bool dp[5010][32780]; int main(){ int i; int j; int flag = 0; cin>>N; fill( dp[0], dp[N], 0 ); for( i = 0; i < N; i++ ){ scanf("%d", A+i); top = max( top, A[i] ); } top *= 2; dp[0][0] = 1; for( i = 1; i <= N; i++ ){ for( j = 0; j <= top; j++ ){ if( dp[i-1][j] ){ idx = j ^ A[i-1]; dp[i][idx] = 1; dp[i][j] = 1; } } } for( i = 0; i <= top; i++ ){ if( dp[N][i] ) ans++; } cout<<ans<<endl; return 0; }