結果
問題 |
No.698 ペアでチームを作ろう
|
ユーザー |
|
提出日時 | 2020-05-13 20:33:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 1,000 ms |
コード長 | 377 bytes |
コンパイル時間 | 2,058 ms |
コンパイル使用メモリ | 190,264 KB |
最終ジャッジ日時 | 2025-01-10 10:48:45 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:19:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 19 | scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:20:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | rep(i,n) scanf("%d",&a[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; int n,a[14]; int dfs(int S){ if(S==(1<<n)-1) return 0; int res=0,i; for(i=0;S>>i&1;i++); for(int j=i+1;j<n;j++) if((S>>j&1)==0) res=max(res,dfs(S|1<<i|1<<j)+(a[i]^a[j])); return res; } int main(){ scanf("%d",&n); rep(i,n) scanf("%d",&a[i]); printf("%d\n",dfs(0)); return 0; }