結果
| 問題 |
No.3249 AND
|
| コンテスト | |
| ユーザー |
Taiki0715
|
| 提出日時 | 2025-08-29 22:52:38 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 96 ms / 2,000 ms |
| コード長 | 837 bytes |
| コンパイル時間 | 806 ms |
| コンパイル使用メモリ | 88,400 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-09-05 11:40:06 |
| 合計ジャッジ時間 | 3,259 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 23 |
ソースコード
#include<iostream>
#include<vector>
#include<cassert>
using namespace std;
int main(){
int n;
cin>>n;
vector<int>b(n);
vector<int>p(30,-1);
for(int i=0;i<n;i++){
cin>>b[i];
for(int j=0;j<30;j++){
int x=b[i]>>j&1;
int y=(i+1)>>j&1;
if(x==1&&y==1){
if(p[j]==0){
cout<<"-1\n";
return 0;
}
p[j]=1;
}
else if(x==1&&y==0){
cout<<"-1\n";
return 0;
}
else if(x==0&&y==1){
if(p[j]==1){
cout<<"-1\n";
return 0;
}
p[j]=0;
}
}
}
int ans=0;
for(int j=0;j<30;j++){
if(p[j]==-1)continue;
if(p[j]==1)ans|=1<<j;
}
if(ans==0){
for(int j=0;j<30;j++){
if(p[j]==-1){
ans|=1<<j;
break;
}
}
}
assert(ans);
cout<<ans<<endl;
}
Taiki0715