Submission #58326


ソースコード

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
37
38
39
40
41
42
43
44
45
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
#define stp(x) setprecision(x)
ll a[25][25];
vlong dp1((1<<20),200000000*10+1);
vlong dp2((1<<20),200000000*10+1);
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,m;
cin>>n;
rep(i,n){
rep(j,n){
cin>>a[i][j];
}
}
dp1[0]=0;
rep(i,n){
rep(j,(1<<n)){
if(dp1[j]!=200000000*10+1){
rep(k,n){
dp2[j | (1<<k)]=min(dp2[j | (1<<k)],dp1[j]+a[i][k]);
}
}
}
rep(j,(1<<n)){
dp1[j]=dp2[j];
dp2[j]=200000000*10+1;
}
}
cout<<dp1[(1<<n)-1]<<'\n';
return(0);
}

ステータス

項目 データ
問題 1108 - 発表会
ユーザー名 ei1918
投稿日時 2020-01-29 18:14:58
言語 C++14
状態 Accepted
得点 1
ソースコード長 1126 Byte
最大実行時間 418 ms
最大メモリ使用量 17124 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
case01.in AC 361 ms 16988 KB
1
case02.in AC 313 ms 17056 KB
1
case03.in AC 403 ms 17124 KB
1
case04.in AC 361 ms 16936 KB
1
case05.in AC 367 ms 17004 KB
1
case06.in AC 389 ms 16808 KB
1
case07.in AC 358 ms 16876 KB
1
case08.in AC 404 ms 16948 KB
1
case09.in AC 326 ms 16888 KB
1
case10.in AC 329 ms 16956 KB
1
case11.in AC 388 ms 16768 KB
1
case12.in AC 402 ms 16960 KB
1
case13.in AC 363 ms 17028 KB
1
case14.in AC 393 ms 16964 KB
1
case15.in AC 336 ms 16900 KB
1
case16.in AC 342 ms 16836 KB
1
case17.in AC 343 ms 17032 KB
1
case18.in AC 326 ms 16844 KB
1
case19.in AC 361 ms 16912 KB
1
case20.in AC 418 ms 16976 KB
1
sample01.in AC 29 ms 17044 KB
1
sample02.in AC 32 ms 16996 KB
1