結果

問題 No.1296 OR or NOR
ユーザー ytftytft
提出日時 2021-05-22 00:15:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,331 bytes
コンパイル時間 7,923 ms
コンパイル使用メモリ 387,996 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-18 17:08:39
合計ジャッジ時間 45,525 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 909 ms
6,940 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 765 ms
6,940 KB
testcase_18 AC 772 ms
6,944 KB
testcase_19 AC 761 ms
6,944 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 522 ms
6,940 KB
testcase_23 AC 527 ms
6,944 KB
testcase_24 AC 583 ms
6,940 KB
testcase_25 AC 572 ms
6,940 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 617 ms
6,940 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mp;


int main(){
    mp N,Q;
    cin>>N;
    vector<int> atlas(60,-1);
    for(int i=0;i<N;i++){
        mp A;
        cin>>A;
        for(int j=0;j<60;++j){
            mp T=A%2;
            if(T==1){
                atlas[j]=i;
            }
            A>>=1;
        }
    }
    cin>>Q;
    for(int i=0;i<Q;++i){
        mp count=0,dec=0;
        map<int,mp> m;
        mp b;
        cin>>b;
        mp odd=-1;
        for(int j=0;j<60;++j){
            mp target=b%2;
            if(atlas[j]==-1){
                if(odd!=-1 && odd!=target){
                    cout<<-1<<endl;
                    goto end;
                }else{
                    odd=target;
                }
            }else{
                if(m.count(atlas[j]) && m[atlas[j]]!=target){
                    cout<<-1<<endl;
                    goto end;
                }else if(!m.count(atlas[j])){
                    ++dec;
                    count+=1-target;
                    m[atlas[j]]=target;
                }
            }
            b>>=1;
        }
        if((count+odd)%2){
            cout<<((dec==N)?(mp)-1:count+1)<<endl;
        }else{
            cout<<count<<endl;
        }
        end:{}
    }

}
0