結果
問題 |
No.3249 AND
|
ユーザー |
|
提出日時 | 2025-08-30 07:14:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 905 bytes |
コンパイル時間 | 1,382 ms |
コンパイル使用メモリ | 163,736 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-05 11:41:16 |
合計ジャッジ時間 | 3,189 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> P; #define REP(i,n) for(ll i=0;i<ll(n);i++) int main(void){ cin.tie(nullptr); ios_base::sync_with_stdio(false); ll i,j; ll n; cin >> n; vector<ll> b(n+1); for(i=1;i<=n;i++) cin >> b[i]; vector<ll> v(20,-1); for(i=1;i<=n;i++){ for(j=0;j<20;j++){ if(b[i]&(1LL<<j)){ if(i&(1LL<<j)){ if(v[j]!=0) v[j]=1; else{ cout << -1 << endl; return 0; } } else{ cout << -1 << endl; return 0; } } else{ if(i&(1LL<<j)){ if(v[j]!=1) v[j]=0; else{ cout << -1 << endl; return 0; } } } } } ll ans=0; REP(i,20){ if(v[i]==1) ans+=1LL<<i; } if(ans>0) cout << ans << endl; else{ REP(i,20){ if(v[i]==-1){ cout << (1LL<<i) << endl; break; } } } return 0; }