結果

問題 No.699 ペアでチームを作ろう2
ユーザー fura
提出日時 2020-05-15 12:38:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 8 ms / 1,000 ms
コード長 402 bytes
コンパイル時間 2,522 ms
コンパイル使用メモリ 190,264 KB
最終ジャッジ日時 2025-01-10 11:05:55
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
main.cpp:24:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |         rep(i,n) scanf("%d",&a[i]);
      |                  ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int n,a[14];

int ans;

void dfs(int S,int val){
	if(S==(1<<n)-1){
		ans=max(ans,val);
		return;
	}

	int i;
	for(i=0;S>>i&1;i++);
	for(int j=i+1;j<n;j++) if((S>>j&1)==0) dfs(S|1<<i|1<<j,val^(a[i]+a[j]));
}

int main(){
	scanf("%d",&n);
	rep(i,n) scanf("%d",&a[i]);

	dfs(0,0);
	printf("%d\n",ans);

	return 0;
}
0