結果
問題 | No.845 最長の切符 |
ユーザー | titia |
提出日時 | 2019-06-28 23:27:02 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 762 bytes |
コンパイル時間 | 456 ms |
コンパイル使用メモリ | 87,132 KB |
実行使用メモリ | 86,036 KB |
最終ジャッジ日時 | 2023-09-14 22:45:32 |
合計ジャッジ時間 | 7,426 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
75,560 KB |
testcase_01 | AC | 74 ms
71,320 KB |
testcase_02 | AC | 73 ms
71,252 KB |
testcase_03 | AC | 74 ms
71,220 KB |
testcase_04 | AC | 74 ms
71,360 KB |
testcase_05 | AC | 74 ms
71,352 KB |
testcase_06 | AC | 75 ms
71,308 KB |
testcase_07 | AC | 72 ms
71,200 KB |
testcase_08 | AC | 96 ms
76,804 KB |
testcase_09 | AC | 82 ms
76,672 KB |
testcase_10 | AC | 621 ms
78,532 KB |
testcase_11 | AC | 118 ms
77,648 KB |
testcase_12 | AC | 120 ms
77,404 KB |
testcase_13 | AC | 108 ms
77,948 KB |
testcase_14 | AC | 94 ms
76,628 KB |
testcase_15 | TLE | - |
testcase_16 | -- | - |
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 sys input = sys.stdin.readline N,M=map(int,input().split()) L=[list(map(int,input().split())) for i in range(M)] for i in range(M): L[i][0]-=1 L[i][1]-=1 LLIST=[[-1]*(N) for i in range(N)] for x,y,z in L: LLIST[x][y]=max(LLIST[x][y],z) LLIST[y][x]=max(LLIST[y][x],z) #from functools import lru_cache #@lru_cache(maxsize=None) def calc(USED,LAST,DIS): #print(bin(USED),LAST,DIS) ANS=DIS for i in range(N): if USED & (1<<i) !=0: continue if LLIST[LAST][i]==-1: continue USED2=USED+(1<<i) ANS=max(ANS,calc(USED2,i,DIS+LLIST[LAST][i])) return ANS ANS=0 for i in range(N): ANS=max(ANS,calc(1<<i,i,0)) print(ANS)