結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー sotanakajimacl1sotanakajimacl1
提出日時 2017-09-16 13:34:57
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 413 bytes
コンパイル時間 652 ms
コンパイル使用メモリ 56,736 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 13:46:32
合計ジャッジ時間 2,271 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 129 ms
6,940 KB
testcase_08 AC 124 ms
6,940 KB
testcase_09 AC 87 ms
6,940 KB
testcase_10 AC 103 ms
6,940 KB
testcase_11 AC 133 ms
6,944 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 138 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 33 ms
6,940 KB
testcase_18 AC 123 ms
6,940 KB
testcase_19 AC 17 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:24: warning: iteration 65536 invokes undefined behavior [-Waggressive-loop-optimizations]
   24 |                 if(dp[i]==1) ans++;
      |                    ~~~~^
main.cpp:23:22: note: within this loop
   23 |         for(int i=0;i<=2<<15;i++){
      |                     ~^~~~~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#define INF (1<<30)
using namespace std;
//yuki 183
//片っぽ○で真
int n,a[5000],dp[1<<15+1],ans;

int main(){
	dp[0]=1;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		dp[a[i]]=1;
	}
	for(int i=0;i<n;i++){
		for(int j=1;j<=1<<15;j++){
			if(dp[j]==1){
				dp[j^(a[i])]=1;
			}
		}
	}
	for(int i=0;i<=2<<15;i++){
		if(dp[i]==1) ans++;
	}
	cout<<ans<<endl;
	return 0;
}
0