結果
| 問題 | No.90 品物の並び替え |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-23 13:05:33 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,102 bytes |
| コンパイル時間 | 363 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 84,296 KB |
| 最終ジャッジ日時 | 2024-10-15 18:08:57 |
| 合計ジャッジ時間 | 7,110 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | TLE * 1 -- * 8 |
ソースコード
N, M = map(int, input().split())
item = [list(map(int, input().split())) for i in range(M)]
from itertools import product
ans = 0
from collections import deque
for i in product(range(2), repeat=M):
X = [[] for i in range(N)]
Y = 0
for j in range(M):
if i[j]:
item1, item2, score = item[j]
X[item1] += [item2]
Y += score
for j in range(N):
visited = [0] * N
visited[j] = 1
que = deque([j])
while que and Y:
q = que.popleft()
for x in X[q]:
if x == j:
Y = 0
break
if visited[x] == 0:
visited[x] = 1
que.append(x)
if Y == 0:
break
ans = max(ans, Y)
print(ans)