結果
問題 | No.654 Air E869120 |
ユーザー | PNJ |
提出日時 | 2023-11-09 02:15:51 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,122 bytes |
コンパイル時間 | 158 ms |
コンパイル使用メモリ | 13,056 KB |
実行使用メモリ | 72,576 KB |
最終ジャッジ日時 | 2024-09-25 23:59:30 |
合計ジャッジ時間 | 45,496 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 33 ms
10,880 KB |
testcase_01 | AC | 35 ms
10,880 KB |
testcase_02 | AC | 35 ms
11,136 KB |
testcase_03 | AC | 33 ms
11,008 KB |
testcase_04 | AC | 33 ms
10,880 KB |
testcase_05 | AC | 32 ms
11,008 KB |
testcase_06 | AC | 33 ms
11,008 KB |
testcase_07 | AC | 32 ms
11,008 KB |
testcase_08 | AC | 34 ms
10,880 KB |
testcase_09 | AC | 33 ms
10,880 KB |
testcase_10 | TLE | - |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | AC | 1,638 ms
28,800 KB |
testcase_17 | AC | 1,655 ms
28,928 KB |
testcase_18 | AC | 1,660 ms
28,672 KB |
testcase_19 | AC | 1,639 ms
28,800 KB |
testcase_20 | AC | 1,469 ms
19,840 KB |
testcase_21 | AC | 1,496 ms
19,968 KB |
testcase_22 | AC | 1,460 ms
19,968 KB |
testcase_23 | AC | 1,465 ms
20,096 KB |
testcase_24 | AC | 1,468 ms
19,712 KB |
testcase_25 | AC | 1,420 ms
19,584 KB |
testcase_26 | AC | 1,482 ms
19,712 KB |
testcase_27 | AC | 1,376 ms
17,024 KB |
testcase_28 | AC | 1,474 ms
16,768 KB |
testcase_29 | AC | 1,358 ms
16,640 KB |
testcase_30 | AC | 1,381 ms
12,032 KB |
testcase_31 | AC | 1,363 ms
12,032 KB |
testcase_32 | AC | 1,356 ms
12,032 KB |
testcase_33 | AC | 1,392 ms
12,032 KB |
testcase_34 | AC | 1,384 ms
11,904 KB |
testcase_35 | AC | 31 ms
10,752 KB |
testcase_36 | AC | 31 ms
10,880 KB |
testcase_37 | AC | 30 ms
10,880 KB |
testcase_38 | AC | 31 ms
10,880 KB |
testcase_39 | AC | 34 ms
11,008 KB |
ソースコード
from collections import deque import sys sys.setrecursionlimit(1000000) input = sys.stdin.readline class Dinic: def __init__(self,V): self.V = V self.E = [[] for i in range(V)] self.P = [0 for i in range(V)] def add_edge(self,u,v,cap): self.E[u].append((v,cap,self.P[v])) self.E[v].append((u,0,self.P[u])) self.P[u] += 1 self.P[v] += 1 def flow(self,s,t): G = self.E P = self.P def bfs(s): #始点から各頂点への最短距離をBFSで求める。 dist = [-1 for i in range(self.V)] dist[s] = 0 Q = deque() Q.append(s) while len(Q) > 0: u = Q.popleft() for v,cap,rev in G[u]: if cap > 0 and dist[v] < 0: dist[v] = dist[u] + 1 Q.append(v) return dist def dfs(u,t,f,removed,dist): if u == t: return f while removed[u] < P[u]: v,cap,rev = G[u][removed[u]] if cap > 0 and dist[u] < dist[v]: ff = dfs(v,t,min(f,cap),removed,dist) if ff > 0: G[u][removed[u]] = (v,cap-ff,rev) u,Cap,Rev = G[v][rev] G[v][rev] = (u,Cap+ff,Rev) return ff removed[u] += 1 return 0 f = 0 while True: dist = bfs(s) if dist[t] < 0: return f removed = [0 for i in range(self.V)] while True: ff = dfs(s,t,10000000000,removed,dist) if ff == 0: break f += ff N,M,d = map(int,input().split()) G = Dinic(2*M+2) X = [0] for i in range(M): u,v,p,q,w = map(int,input().split()) G.add_edge(2*i+1,2*i+2,w) X.append((u,p,0)) X.append((v,q,1)) inf = 10**18 for i in range(1,2*M+1): v,t,f = X[i] if f == 0: if v == 1: G.add_edge(0,i,inf) else: if v == N: G.add_edge(i,2*M+1,inf) for j in range(1,2*M+1): u,tt,ff = X[j] if f == 0 and ff == 0: if u == v: if t <= tt: G.add_edge(i,j,inf) if t >= tt: G.add_edge(j,i,inf) if f == 1 and ff == 0: if t + d <= tt and u == v: G.add_edge(i,j,inf) ans = G.flow(0,2*M+1) print(ans)