結果
問題 |
No.519 アイドルユニット
|
ユーザー |
|
提出日時 | 2020-12-13 23:46:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 64 ms / 1,000 ms |
コード長 | 494 bytes |
コンパイル時間 | 2,025 ms |
コンパイル使用メモリ | 190,848 KB |
最終ジャッジ日時 | 2025-01-17 00:11:40 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:28:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 28 | scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:29:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 29 | rep(i,n) rep(j,n) scanf("%d",&A[i][j]); | ~~~~~^~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; int n,A[24][24]; int memo[1<<24]; int dfs(int S){ int& res=memo[S]; if(res!=-1) return res; if(S==(1<<n)-1) return res=0; int i; for(i=0;S>>i&1;i++); res=0; for(int j=i+1;j<n;j++) if(~S>>j&1) { res=max(res,dfs(S|1<<i|1<<j)+A[i][j]); } return res; } int main(){ scanf("%d",&n); rep(i,n) rep(j,n) scanf("%d",&A[i][j]); memset(memo,-1,sizeof memo); printf("%d\n",dfs(0)); return 0; }