結果
問題 | No.845 最長の切符 |
ユーザー | pengincoalition |
提出日時 | 2019-07-05 18:49:13 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 762 bytes |
コンパイル時間 | 430 ms |
コンパイル使用メモリ | 11,836 KB |
実行使用メモリ | 39,868 KB |
最終ジャッジ日時 | 2023-10-22 01:58:52 |
合計ジャッジ時間 | 7,316 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 30 ms
10,224 KB |
testcase_01 | AC | 30 ms
10,236 KB |
testcase_02 | AC | 30 ms
10,416 KB |
testcase_03 | AC | 27 ms
10,224 KB |
testcase_04 | AC | 27 ms
10,228 KB |
testcase_05 | AC | 28 ms
10,224 KB |
testcase_06 | AC | 28 ms
10,224 KB |
testcase_07 | AC | 28 ms
10,224 KB |
testcase_08 | AC | 32 ms
10,348 KB |
testcase_09 | AC | 29 ms
10,244 KB |
testcase_10 | AC | 82 ms
10,928 KB |
testcase_11 | AC | 35 ms
10,288 KB |
testcase_12 | AC | 41 ms
10,520 KB |
testcase_13 | AC | 30 ms
10,280 KB |
testcase_14 | AC | 34 ms
10,452 KB |
testcase_15 | AC | 887 ms
17,076 KB |
testcase_16 | TLE | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
ソースコード
import copy N,M=tuple(map(int,input().split(' '))) x=[[-1 for j in range(N)] for i in range(N)] for i in range(M): temp1,temp2,temp3=tuple(map(int,input("").split(" "))) temp1-=1 temp2-=1 x[temp1][temp2]=max([temp3,x[temp2][temp1]]) x[temp2][temp1]=max([temp3,x[temp2][temp1]]) dp_s=[] if True: dp=[[-1 for j in range(N)] for i in range(1<<N)] for i in range(N): dp[1<<i][i]=0 A=-100000000000000000 for i2 in range(0,1<<N): for i3 in range(N): if dp[i2][i3]>=0: A=max([A,dp[i2][i3]]) for j in range(N): if x[i3][j]>=0 and not(i2&(1<<j)): dp[i2|(1<<j)][j]=max([dp[i2][i3]+x[i3][j],dp[i2|(1<<j)][j]]) print(A)