結果
問題 |
No.3249 AND
|
ユーザー |
|
提出日時 | 2025-08-29 23:06:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 805 bytes |
コンパイル時間 | 3,008 ms |
コンパイル使用メモリ | 162,432 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2025-08-30 00:00:37 |
合計ジャッジ時間 | 2,520 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 WA * 1 |
ソースコード
#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; } cout << ans << endl; return 0; }