結果
| 問題 |
No.183 たのしい排他的論理和(EASY)
|
| コンテスト | |
| ユーザー |
akakimidori
|
| 提出日時 | 2015-07-26 19:25:10 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 625 bytes |
| コンパイル時間 | 291 ms |
| コンパイル使用メモリ | 21,248 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-08 14:09:50 |
| 合計ジャッジ時間 | 899 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | WA * 18 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:12:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d",&N);
| ^~~~~~~~~~~~~~
main.c:18:26: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | for(i=0;i<N;i++) scanf("%d\n",&A[i]);
| ^~~~~~~~~~~~~~~~~~~
ソースコード
#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]=0;
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;
}
akakimidori