結果

問題 No.519 アイドルユニット
ユーザー vjudge1
提出日時 2025-03-15 15:59:22
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 673 bytes
コンパイル時間 1,869 ms
コンパイル使用メモリ 161,164 KB
実行使用メモリ 82,024 KB
最終ジャッジ日時 2025-03-15 15:59:37
合計ジャッジ時間 15,116 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28 TLE * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
main.cpp:12:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |             scanf("%d",&v[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~

ソースコード

diff #

#include<bits/stdc++.h>
#define inf 0x3f3f3f3f3f3f3f3f
#define N 30
#define M 20000007
using namespace std;
int v[N][N],n,f[M];
signed main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            scanf("%d",&v[i][j]);
    memset(f,-0x3f,sizeof(f));
    f[0]=0;
    for(int i=0;i<(1<<n);i++)
    {
        if(f[i]==-inf)continue;
        int id=0;
        for(int j=1;j<=n;j++)
        {
            if(!(i&(1<<(j-1))))
            {
                if(id==0)id=j;
                else f[i|(1<<(id-1))|(1<<(j-1))]=max(f[i|(1<<(id-1))|(1<<(j-1))],f[i]+v[id][j]);
            }
        }
    }
    printf("%d ",f[(1<<n)-1]);
    return 0;
}
0