結果

問題 No.183 たのしい排他的論理和(EASY)
コンテスト
ユーザー TLwiegehtt
提出日時 2015-07-15 11:23:25
言語 C90(gcc12)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 115 ms / 5,000 ms
+ 67µs
コード長 438 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,241 ms
コンパイル使用メモリ 30,020 KB
実行使用メモリ 9,796 KB
最終ジャッジ日時 2026-10-12 14:33:44
合計ジャッジ時間 3,273 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%d", &n);
      |         ^~~~~~~~~~~~~~~
main.c:14:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |                 scanf("%d", &a);
      |                 ^~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <stdio.h>


char dp[3][32780];

int main(void){
	int i,j,n;
	int cnt=0;
	scanf("%d", &n);
	
	dp[0][0] = 1;
	for(i=1;i<=n;i++){
		int a;
		scanf("%d", &a);
		for(j=0;j<32780;j++){
			int front = (i+1)%2;
			int now = i%2;
			
			if(dp[front][j] == 1){
				int xor = a^j;
				dp[now][xor] = 1;
				dp[now][j] = 1;
			}
			
		}
	}
	
	for(i=0;i<32780;i++){
		if(dp[n%2][i] == 1){
			cnt++;
		}
	}
	
	printf("%d\n", cnt);
	return 0;
}
0