Submission #48884


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include<bits/stdc++.h>
using namespace std;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
long long a[32][32];
long long dp[1<<20];
int n;
long long dfs ( int cnt, int bit ) {
if ( ~dp[bit] ) return dp[bit];
if ( cnt == n ) return 0;
long long rec = LINF;
for ( int i = 0; i < n; i++ ) {
if ( bit & ( 1<<i ) ) continue;
rec = min ( rec, dfs ( cnt+1, bit|(1<<i) ) + a[i][cnt] );
}
return dp[bit] = rec;
}
signed main() {
scanf("%d", &n);
for ( int i = 0; i < n; i++ ) {
for ( int j = 0; j < n; j++ ) {
scanf("%lld", &a[i][j]);
}
}
memset(dp, -1, sizeof(dp));
printf("%lld\n", dfs (0, 0));
return 0;
}

ステータス

項目 データ
問題 1108 - 発表会
ユーザー名 r1825
投稿日時 2019-04-26 22:07:39
言語 C++
状態 Accepted
得点 1
ソースコード長 735 Byte
最大実行時間 118 ms
最大メモリ使用量 8900 KB

セット

セット 得点 Cases
1 ALL 1 / 1 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
case01.in AC 106 ms 8792 KB
1
case02.in AC 110 ms 8884 KB
1
case03.in AC 103 ms 8716 KB
1
case04.in AC 101 ms 8680 KB
1
case05.in AC 96 ms 8772 KB
1
case06.in AC 99 ms 8740 KB
1
case07.in AC 115 ms 8832 KB
1
case08.in AC 113 ms 8796 KB
1
case09.in AC 98 ms 8884 KB
1
case10.in AC 107 ms 8848 KB
1
case11.in AC 116 ms 8804 KB
1
case12.in AC 113 ms 8900 KB
1
case13.in AC 118 ms 8736 KB
1
case14.in AC 101 ms 8696 KB
1
case15.in AC 100 ms 8656 KB
1
case16.in AC 103 ms 8748 KB
1
case17.in AC 102 ms 8712 KB
1
case18.in AC 118 ms 8804 KB
1
case19.in AC 113 ms 8764 KB
1
case20.in AC 100 ms 8852 KB
1
sample01.in AC 26 ms 8820 KB
1
sample02.in AC 24 ms 8788 KB
1