結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー hiromi-mihiromi-mi
提出日時 2018-12-31 11:42:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 159 ms / 5,000 ms
コード長 736 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 62,836 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 22:00:55
合計ジャッジ時間 2,462 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 140 ms
4,380 KB
testcase_08 AC 140 ms
4,380 KB
testcase_09 AC 96 ms
4,380 KB
testcase_10 AC 116 ms
4,380 KB
testcase_11 AC 152 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 159 ms
4,376 KB
testcase_15 AC 156 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 36 ms
4,376 KB
testcase_18 AC 136 ms
4,380 KB
testcase_19 AC 19 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:38:18: warning: iteration 65536 invokes undefined behavior [-Waggressive-loop-optimizations]
       ans += dp[i];
              ~~~~^
main.cpp:16:30: note: within this loop
 #define rep(i,b) for(ll i=0;i<(b);++i)
                              ^
main.cpp:37:4: note: in expansion of macro ‘rep’
    rep(i, (1 << 16)+1) {
    ^~~

ソースコード

diff #

#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;
}
0