結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー deark1414deark1414
提出日時 2017-10-05 17:13:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 613 bytes
コンパイル時間 435 ms
コンパイル使用メモリ 63,876 KB
実行使用メモリ 323,708 KB
最終ジャッジ日時 2024-04-28 07:39:30
合計ジャッジ時間 7,051 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 203 ms
323,456 KB
testcase_01 AC 206 ms
323,492 KB
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 AC 206 ms
323,480 KB
testcase_14 AC 208 ms
323,488 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:35: warning: iteration 65536 invokes undefined behavior [-Waggressive-loop-optimizations]
   24 |                         if(dp[i][j]){
      |                            ~~~~~~~^
main.cpp:23:33: note: within this loop
   23 |                 for(int j = 0;j <= lim;j++){
      |                               ~~^~~~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>

using namespace std;
const int lim = 1<<15 + 1;
bool dp[5001][lim];
int main(){
	memset(dp,0,sizeof(dp));
	int n;
	cin >> n;
	
	vector<int> a;
	for(int i = 0;i < n;i++){
		int ta;
		cin >> ta;
		if(find(a.begin(),a.end(),ta) == a.end()) a.push_back(ta);
	}
	
	dp[0][0] = true;
	for(int i = 0;i < a.size();i++){
		for(int j = 0;j <= lim;j++){
			if(dp[i][j]){
				dp[i+1][j] = true;
				dp[i+1][j ^ a[i]] = true;
			}
		}
	}
	
	int ans = 0;
	for(int i = 0;i <= 20;i++){
		if(dp[a.size()][i]) ans++;
	}
	
	cout << ans << endl;
	return 0;
}
0