結果
問題 | No.183 たのしい排他的論理和(EASY) |
ユーザー |
![]() |
提出日時 | 2017-12-17 23:03:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,347 bytes |
コンパイル時間 | 2,084 ms |
コンパイル使用メモリ | 172,080 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-23 06:09:46 |
合計ジャッジ時間 | 5,921 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 2 |
other | RE * 18 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:19:17: warning: 'N' is used uninitialized [-Wuninitialized] 19 | Vl A(N,0); | ^ main.cpp:18:15: note: 'N' declared here 18 | short N; | ^
ソースコード
#include <bits/stdc++.h> #define REP(i,n) for (int i=0;i<(n);i++) #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define dump(x) cerr << #x << " => " << (x) << endl; #define dump1d_arr(array,i) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl; #define dump2d_arr(array,i,j) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl; #define loINF (long)10000000000 #define shINF (short)10000 #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define CLR(a) memset((a), 0 ,sizeof(a)) using namespace std; typedef vector<long> Vl; typedef vector<short> VS; int main(void){ short N; Vl A(N,0); long tmpmax = 0; long maxval = 0; short iter = 0; cin >> N; REP(i,N){ cin >> A[i]; tmpmax = MAX(A[i],tmpmax); } #ifdef DEBUG REP(i,N) dump1d_arr(A,i); #endif while(tmpmax > maxval){ maxval += (1 << (iter++)); } #ifdef DEBUG dump(maxval); #endif VS initdp(maxval+1,0); VS dp_tmp(maxval+1,0); VS dp(maxval+1,0); dp[0] = 1; REP(i,N){ dp_tmp = initdp; REP(j,maxval+1){ #ifdef DEBUG dump(i); dump(j); #endif if (dp[j]){ dp_tmp[j^(A[i])] = 1; dp_tmp[j] = 1; } } dp = dp_tmp; } #ifdef DEBUG REP(i,dp.size()) dump1d_arr(dp,i); #endif //(DEBUG) cout << count(dp.begin(),dp.end(),1) << endl; return 0; }