結果
問題 | No.654 Air E869120 |
ユーザー | 山本信二 |
提出日時 | 2022-03-23 07:37:26 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,872 bytes |
コンパイル時間 | 471 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 73,984 KB |
最終ジャッジ日時 | 2024-10-11 04:51:11 |
合計ジャッジ時間 | 4,373 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 62 ms
65,536 KB |
testcase_31 | AC | 62 ms
65,280 KB |
testcase_32 | AC | 62 ms
65,408 KB |
testcase_33 | AC | 62 ms
65,024 KB |
testcase_34 | AC | 61 ms
65,152 KB |
testcase_35 | AC | 43 ms
53,632 KB |
testcase_36 | AC | 42 ms
54,272 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
ソースコード
from collections import deque INF = 10 ** 11 class Dinic: def __init__(self, N): self.N = N self.G = [[] for i in range(N)] def add_edge(self, fr, to, cap): forward = [to, cap, None] forward[2] = backward = [fr, 0, forward] self.G[fr].append(forward) self.G[to].append(backward) def add_multi_edge(self, v1, v2, cap1, cap2): edge1 = [v2, cap1, None] edge1[2] = edge2 = [v1, cap2, edge1] self.G[v1].append(edge1) self.G[v2].append(edge2) def bfs(self, s, t): self.level = level = [None]*self.N deq = deque([s]) level[s] = 0 G = self.G while deq: v = deq.popleft() lv = level[v] + 1 for w, cap, _ in G[v]: if cap and level[w] is None: level[w] = lv deq.append(w) return level[t] is not None def dfs(self, v, t, f): if v == t: return f level = self.level for e in self.it[v]: w, cap, rev = e if cap and level[v] < level[w]: d = self.dfs(w, t, min(f, cap)) if d: e[1] -= d rev[1] += d return d return 0 def flow(self, s, t): flow = 0 INF = 10**9 + 7 G = self.G while self.bfs(s, t): *self.it, = map(iter, self.G) f = INF while f: f = self.dfs(s, t, INF) flow += f return flow N,M,D = map(int, input().split()) t = [0] * N dinic = Dinic(N) for i in range(M): u, v, p,q,c = map(int, input().split()) if u > t[u-1]: dinic.add_edge(u-1, v-1, c) else: dinic.add_edge(u-1,v-1,INF) t[v-1] = min(t[v-1],q+D) print(dinic.flow(0, N-1))