結果

問題 No.845 最長の切符
ユーザー yuruhiyayuruhiya
提出日時 2020-10-20 18:46:46
言語 cLay
(20240104-1)
結果
AC  
実行時間 332 ms / 3,000 ms
コード長 426 bytes
コンパイル時間 2,233 ms
コンパイル使用メモリ 165,860 KB
実行使用メモリ 15,756 KB
最終ジャッジ日時 2023-09-19 01:40:39
合計ジャッジ時間 5,303 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,324 KB
testcase_01 AC 2 ms
5,384 KB
testcase_02 AC 2 ms
5,436 KB
testcase_03 AC 2 ms
5,516 KB
testcase_04 AC 2 ms
5,432 KB
testcase_05 AC 2 ms
5,536 KB
testcase_06 AC 2 ms
5,356 KB
testcase_07 AC 2 ms
5,424 KB
testcase_08 AC 2 ms
5,432 KB
testcase_09 AC 2 ms
5,324 KB
testcase_10 AC 3 ms
5,780 KB
testcase_11 AC 2 ms
5,424 KB
testcase_12 AC 2 ms
5,508 KB
testcase_13 AC 2 ms
5,460 KB
testcase_14 AC 3 ms
5,468 KB
testcase_15 AC 20 ms
9,432 KB
testcase_16 AC 332 ms
15,672 KB
testcase_17 AC 83 ms
9,472 KB
testcase_18 AC 60 ms
11,568 KB
testcase_19 AC 17 ms
6,616 KB
testcase_20 AC 95 ms
15,756 KB
testcase_21 AC 60 ms
15,584 KB
testcase_22 AC 73 ms
9,460 KB
testcase_23 AC 16 ms
5,868 KB
testcase_24 AC 274 ms
15,580 KB
testcase_25 AC 2 ms
5,420 KB
testcase_26 AC 13 ms
15,564 KB
testcase_27 AC 2 ms
5,416 KB
testcase_28 AC 13 ms
15,576 KB
testcase_29 AC 2 ms
5,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

vector<ll> to[16],cost[16];
ll dp[1d5][16];
{
	ll@n, @m;
	rep(m){
		ll@u,@v,@c;
		to[--u].push_back(--v);
		cost[u].push_back(c);
		to[v].push_back(u);
		cost[v].push_back(c);
	}
	dp[0..(1<<n)-1][0...n-1]=-1;
	dp[1<<(0..n-1)][0..]=0;
	rep(s,1<<n)rep(v,n)if(dp[s][v]!=-1){
		rep(i,to[v].size())if(!(s&1<<to[v][i]))dp[s|1<<to[v][i]][to[v][i]] >?= dp[s][v]+cost[v][i];
	}
	ll ans=0;
	ans >?= dp[0..(1<<n)-1][0...n-1];
	wt(ans);
}
0