結果
| 問題 |
No.699 ペアでチームを作ろう2
|
| ユーザー |
ngtkana
|
| 提出日時 | 2020-04-03 14:57:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 1,000 ms |
| コード長 | 1,121 bytes |
| コンパイル時間 | 2,098 ms |
| コンパイル使用メモリ | 198,040 KB |
| 最終ジャッジ日時 | 2025-01-09 12:40:26 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
void cmx(lint&x,lint y){if(x<y)x=y;}
int main(){
std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
lint n;std::cin>>n;
std::vector<lint>a(n);
for(lint&x:a)std::cin>>x;
auto cal=[&a,n](std::vector<std::pair<lint,lint>>const&ind){
return std::accumulate(ind.begin(),ind.end(),0ll,
[&a](lint acc,std::pair<lint,lint>const&p){return acc^(a.at(p.first)+a.at(p.second));});
};
lint ans=0;
auto dfs=[&,n,ckd=std::vector<lint>(n),ind=std::vector<std::pair<lint,lint>>()]
(auto&&f) mutable
{
lint i=0,j=0;
for(;i<n&&std::exchange(ckd.at(i),true);i++);
if(i==n){
cmx(ans,cal(ind));
return;
}
for(;j<n;j++){
if(std::exchange(ckd.at(j),true))continue;
ind.emplace_back(i,j);
f(f);
ind.pop_back();
ckd.at(j)=false;
}
ckd.at(i)=false;
};
dfs(dfs);
std::cout<<ans<<'\n';
}
ngtkana