結果

問題 No.519 アイドルユニット
ユーザー vjudge1
提出日時 2025-03-15 15:51:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 774 ms / 1,000 ms
コード長 2,215 bytes
コンパイル時間 1,698 ms
コンパイル使用メモリ 160,344 KB
実行使用メモリ 69,120 KB
最終ジャッジ日時 2025-03-15 15:51:47
合計ジャッジ時間 8,882 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define MAXN 27 
using namespace std;

inline int read(){
	int x=0;
	char c=getchar();
	while(c<'0' || c>'9'){
		c=getchar();
	}
	while(c>='0' && c<='9'){
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	return x;
}

int n;
int f[1<<MAXN];
int val[MAXN][MAXN];

int check(int num){
    int cnt=0;
    while(num){
        num&=(num-1);
        cnt++;
    }
    return cnt;
}

signed main(){
//	freopen("gourp.in","r",stdin);
//	freopen("group.out","w",stdout);
	n=read();
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			val[i][j]=read();
		}
	}
	int ans=0;
	for(int i=0;i<(1<<n);i++){
		if((__builtin_popcount(i)&1)==0){
			ans=max(ans,f[i]);
			for(int j=0;j<n;j++){
				if((i&(1<<j))==0){
					for(int k=j+1;k<n;k++){
						if((i&(1<<k))==0){
							int x=i|(1<<j)|(1<<k);
							f[x]=max(f[x],f[i]+val[j][k]);
							ans=max(ans,f[x]);
						}
					}
					break;
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}
/*??
??????
???????????????????????
????????????????????
???????????5???????????????????????????????????????????????????????????????????????????????????????????????24?????????????????????????????????????????????????????????????????????
????????????????????
???????????????????????????????????????????????????????????????????????????????????????????...?????????????
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...????????????????????????????????
??????????????
????????????
?????????????
?????????????
?????????
??? ? ?? ? ???????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????
?????????????????????
????????????????????
?????????????
????????????????
????????????????????????
?????????????????????????
??????
??????????????
????????????
???????????????????
????????????
??????
?????
???????????
??????????????
?????
?????
?????
??????
???????????????
??????????
??????????????
????????????
????*/
0