結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー hiromi-mihiromi-mi
提出日時 2018-12-31 11:42:04
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 763 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 63,360 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 06:25:04
合計ジャッジ時間 2,324 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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:39:18: warning: iteration 65536 invokes undefined behavior [-Waggressive-loop-optimizations]
   39 |       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:38:4: note: in expansion of macro ‘rep’
   38 |    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;
   }
   cout << "Done" << endl;
   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