結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー akakimidoriakakimidori
提出日時 2015-07-26 19:25:58
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 204 ms / 5,000 ms
コード長 625 bytes
コンパイル時間 897 ms
コンパイル使用メモリ 25,020 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-11 12:00:02
合計ジャッジ時間 2,921 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 204 ms
4,380 KB
testcase_08 AC 110 ms
4,376 KB
testcase_09 AC 77 ms
4,380 KB
testcase_10 AC 92 ms
4,376 KB
testcase_11 AC 121 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 0 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 125 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 28 ms
4,376 KB
testcase_18 AC 161 ms
4,376 KB
testcase_19 AC 15 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

#define ABS(x) ((x)>0?(x):-(x))
#define MAX(a,b) ((a)>(b)?(a):(b))

typedef long long int ln;

int main(void){

	int N;
	scanf("%d",&N);

	int *A;
	A=(int *)malloc(sizeof(int)*N);

	int i;
	for(i=0;i<N;i++) scanf("%d\n",&A[i]);

	int UP=1<<15;
	char *can;
	can=(char *)malloc(sizeof(char)*UP);

	for(i=0;i<UP;i++) can[i]=0;

	can[0]=1;
	int max=0;
	for(i=0;i<N;i++){
		int j;
		for(j=0;j<=max;j++){
			if(can[j]){
				int t=j^A[i];
				can[t]=1;
				max=MAX(max,t);
			}
		}
	}

	int count=0;
	for(i=0;i<=max;i++) count+=can[i];
	printf("%d\n",count);
	free(A);
	free(can);
	return 0;
}
0