結果

問題 No.1744 Selfish Spies 1 (à la Princess' Perfectionism)
ユーザー kozykozy
提出日時 2021-11-14 21:41:51
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 2,050 bytes
コンパイル時間 778 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 285,128 KB
最終ジャッジ日時 2023-08-20 06:23:40
合計ジャッジ時間 21,082 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
71,536 KB
testcase_01 AC 101 ms
71,656 KB
testcase_02 AC 103 ms
72,052 KB
testcase_03 AC 100 ms
71,568 KB
testcase_04 AC 100 ms
71,360 KB
testcase_05 AC 102 ms
71,568 KB
testcase_06 AC 100 ms
71,240 KB
testcase_07 AC 99 ms
71,292 KB
testcase_08 AC 101 ms
71,244 KB
testcase_09 AC 256 ms
79,764 KB
testcase_10 AC 189 ms
79,936 KB
testcase_11 AC 279 ms
81,696 KB
testcase_12 AC 466 ms
84,632 KB
testcase_13 AC 306 ms
81,780 KB
testcase_14 AC 981 ms
102,444 KB
testcase_15 AC 484 ms
89,828 KB
testcase_16 AC 1,284 ms
131,572 KB
testcase_17 AC 2,880 ms
221,916 KB
testcase_18 AC 2,664 ms
258,816 KB
testcase_19 AC 215 ms
80,348 KB
testcase_20 AC 210 ms
79,844 KB
testcase_21 AC 286 ms
82,332 KB
testcase_22 AC 485 ms
85,000 KB
testcase_23 AC 310 ms
82,836 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import deque
class Dinic():
  def __init__(self,V):
    self.v=V#頂点数
    self.G=[list() for i in range(self.v)]
    self.inf=float("inf")
    self.level=[-1]*self.v
    self.see=[0]*self.v
  def add(self,fro,to,cost):
    self.G[fro].append([cost,to,len(self.G[to])])#cost,to,rev
    self.G[to].append([0,fro,len(self.G[fro])-1])
  #sから各辺の距離をbfsで求める
  def bfs(self,s):
    self.level=[-1]*self.v
    self.level[s]=0
    d=deque()
    d.append(s)
    while d:
      site=d.popleft()
      for e in self.G[site]:
        if self.level[e[1]]==-1 and e[0]>0:
          self.level[e[1]]=self.level[site]+1
          d.append(e[1])
  #フローをsからtへ、f流すとどうなるか
  #増加
  def dfs(self,s,t,f):
    if s==t:
      return f
    for i in range(self.see[s],len(self.G[s])):
      e=self.G[s][i]
      self.see[s]=i
      if e[0]>0 and self.level[s]<self.level[e[1]]:
        d=self.dfs(e[1],t,min(f,e[0]))
        if d!=0:
          self.G[s][i][0]-=d
          self.G[e[1]][e[2]][0]+=d
          return d
    return 0
  def maxflow(self,s,t):
    ans=0
    while True:
      self.bfs(s)
      if self.level[t]<0:
        return ans
      self.see=[0]*self.v
      d=self.dfs(s,t,self.inf)
      while d>0:
        ans+=d
        d=self.dfs(s,t,self.inf)
N,M,L=map(int,input().split())
A=list()
G=Dinic(N+M+2)
for i in range(L):
  a,b=map(int,input().split())
  A.append((a,N+b))
  G.add(a,N+b,1)
for i in range(N):
  G.add(0,i+1,1)
for i in range(M):
  G.add(N+i+1,N+M+1,1)
aaaa=G.maxflow(0,N+M+1)
L=G.G
R=list()
K=list()
for i in range(1,N+1):
  for a,b,c in L[i]:
    if a==0:
      K.append([i,b])
S=set()
for n,m in K:
  G=Dinic(N+M+2)
  for a,b in A:
    if (a,b)==(n,m):
      continue
    G.add(a,b,1)
  for i in range(N):
    G.add(0,i+1,1)
  for i in range(M):
    G.add(N+i+1,N+M+1,1)
  a2=G.maxflow(0,N+M+1)
  if aaaa!=a2:
    S.add((n,m))
for i in A:
  if i in S:
    print("No")
  else:
    print("Yes")
0