結果
| 問題 |
No.519 アイドルユニット
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-13 22:59:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,014 bytes |
| コンパイル時間 | 1,046 ms |
| コンパイル使用メモリ | 117,064 KB |
| 最終ジャッジ日時 | 2025-02-23 22:43:35 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 TLE * 6 |
ソースコード
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include<cassert>
#include<random>
#include<set>
#include<map>
#include<cassert>
#include<unordered_map>
#include<bitset>
#include<numeric>
#include<algorithm>
using namespace std;
typedef long long ll;
const int inf=1<<30;
const ll INF=1LL<<62;
typedef pair<int,ll> P;
typedef pair<int,P> PP;
const ll MOD=998244353;
int main(){
int N;
cin>>N;
vector<vector<int>> F(N,vector<int>(N));
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
cin>>F[i][j];
}
}
vector<int> dp(1<<N,-inf);
dp[0]=0;
for(int S=0;S<(1<<N);S++){
int idx=-1;
for(int i=0;i<N;i++){
if(S>>i&1) continue;
idx=i;
break;
}
if(idx==-1) continue;
for(int j=idx+1;j<N;j++){
if(S>>j&1) continue;
dp[S|(1<<idx)|(1<<j)]=max(dp[S|(1<<idx)|(1<<j)],dp[S]+F[idx][j]);
}
}
int all=(1<<N)-1;
cout<<dp[all]<<endl;
}