結果
| 問題 |
No.1296 OR or NOR
|
| コンテスト | |
| ユーザー |
ytft
|
| 提出日時 | 2021-05-22 00:15:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,331 bytes |
| コンパイル時間 | 7,141 ms |
| コンパイル使用メモリ | 388,404 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-10 10:26:18 |
| 合計ジャッジ時間 | 45,800 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 9 WA * 24 |
ソースコード
#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:{}
}
}
ytft