結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー tottoripaper
提出日時 2015-05-23 18:54:48
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 686 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 34,396 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-04 11:52:44
合計ジャッジ時間 2,338 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 WA * 31
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |     scanf("%d", &N);
      |     ~~~~~^~~~~~~~~~
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%lld", A+i);
      |         ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <algorithm>

typedef long long ll;

int N;
ll A[100000];

int main(){
    scanf("%d", &N);
    for(int i=0;i<N;i++){
        scanf("%lld", A+i);
    }
    
    for(int i=0;i<60;i++){
        {
            int j;
            for(j=0;j<N;j++){
                if(A[j] >> i & 1){break;}
            }

            if(j == N){continue;}

            std::swap(A[j], A[i]);
        }

        for(int j=0;j<N;j++){
            if(j == i){continue;}
            if(!(A[j] >> i & 1)){continue;}
            A[j] ^= A[i];
        }
    }

    int res = 0;
    for(int i=0;i<N;i++){
        if(A[i] > 0){++res;}
    }

    printf("%lld\n", 1ll << res);
}
            
0