結果
| 問題 | No.3550 Another Rurumaru Function Problem |
| コンテスト | |
| ユーザー |
Tehom
|
| 提出日時 | 2026-05-23 00:15:00 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,661 bytes |
| 記録 | |
| コンパイル時間 | 3,674 ms |
| コンパイル使用メモリ | 279,672 KB |
| 実行使用メモリ | 23,168 KB |
| 最終ジャッジ日時 | 2026-05-23 00:15:15 |
| 合計ジャッジ時間 | 10,797 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 22 WA * 19 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repl(i,a,b) for(ll i=(a);i<(b);i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
template <typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;} return false;}
template <typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;} return false;}
void solve(){
int n; cin >> n;
vector<int> a(n);
rep(i,0,n) cin >> a[i];
set<pair<int,int>> st;;
rep(i,0,n) st.insert({0,i});
for(int i=29;i>=0;i--){
if(i%2){
set<pair<int,int>> nst;
for(auto [x,id]:st){
if(a[id]>>i&1){
nst.insert({x-(1<<i),id});
}
else{
nst.insert({x,id});
}
}
swap(st,nst);
}
else{
int mx=-st.begin()->first;
bool ch=false;
for(auto [x,id]:st){
if(a[id]>>i&1 && mx == -x) ch=true;
}
set<pair<int,int>> nst;
if(ch){
for(auto [x,id]:st){
if(a[id]>>i&1) nst.insert({x,id});
}
swap(st,nst);
}
}
}
int ans=0;
rep(i,0,30){
if(i%2 == 0){
bool ch=true;
for(auto [x,id]:st){
if(!(a[id]>>i&1)) ch=false;
}
if(ch) ans+=1<<i;
}
else{
bool ch=false;
for(auto [x,id]:st){
if(a[id]>>i&1) ch=true;
}
if(ch) ans+=1<<i;
}
}
// for(auto [x,id]:st) cout << id << " "; cout << "\n";
cout << ans << "\n";
return;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T=1;
// cin >> T;
while(T--) solve();
}
Tehom