結果

問題 No.2895 Zero XOR Subset
ユーザー とんぼとんぼ
提出日時 2024-09-20 22:55:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,402 bytes
コンパイル時間 1,748 ms
コンパイル使用メモリ 175,400 KB
実行使用メモリ 6,980 KB
最終ジャッジ日時 2024-09-20 22:55:48
合計ジャッジ時間 8,660 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,784 KB
testcase_01 AC 4 ms
6,784 KB
testcase_02 WA -
testcase_03 AC 4 ms
6,784 KB
testcase_04 AC 3 ms
6,784 KB
testcase_05 AC 4 ms
6,784 KB
testcase_06 WA -
testcase_07 AC 3 ms
6,656 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 5 ms
6,912 KB
testcase_11 AC 4 ms
6,784 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 4 ms
6,784 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 3 ms
6,912 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 3 ms
6,784 KB
testcase_21 AC 3 ms
6,784 KB
testcase_22 WA -
testcase_23 AC 4 ms
6,912 KB
testcase_24 AC 4 ms
6,912 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 4 ms
6,784 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 3 ms
6,784 KB
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(i=0;i<N;i++)
#define ll long long

int main(void){
    ll N;
    ll A[200009]={0};
    ll B[200009]={0};

    ll i,j,k;

    cin>>N;
    rep(i,N)cin>>A[i];
    rep(i,N)B[i]=A[i];

    bool pivot[200009]={0};
    vector<ll> use(60,-1);

    for(k=59;0<=k;k--){
        rep(j,N){
            if(pivot[j])continue;
            if((A[j]&(1LL<<k))!=0)break;
        }
        if(j==N)continue;
        pivot[j]=1;
        use[k]=j;
        rep(i,N){
            if(i==j)continue;
            if((A[i]&(1LL<<k))==0)continue;
            A[i]^=A[j];
        }
    }

    bool ans=0;
    rep(i,N){
        if(A[i]==0){
            ans=1;
            vector<ll>list;
            list.push_back(i);
            for(k=59;0<=k;k--){
                if(use[k]==-1)continue;
                if((B[i]^B[use[k]])<=B[i]){
                    B[i]^=B[use[k]];
                    list.push_back(use[k]);
                }
                for(j=k-1;0<=j;j--){
                    if((B[use[k]]^B[use[j]])<=B[use[j]]){
                        B[use[j]]^=B[use[k]];
                    }
                }
            }
            sort(list.begin(),list.end());
            cout<<list.size()<<endl;
            rep(j,list.size())cout<<list[j]+1<<' ';
            cout<<endl;
            break;
        }
    }
    if(ans==0)cout<<-1<<endl;

    return 0;
}
0