結果

問題 No.1744 Selfish Spies 1 (à la Princess' Perfectionism)
ユーザー kozykozy
提出日時 2021-11-14 21:49:23
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 2,203 bytes
コンパイル時間 1,359 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 95,484 KB
最終ジャッジ日時 2023-08-20 06:34:36
合計ジャッジ時間 30,756 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
71,596 KB
testcase_01 AC 92 ms
71,496 KB
testcase_02 AC 105 ms
76,028 KB
testcase_03 AC 91 ms
71,612 KB
testcase_04 AC 91 ms
71,628 KB
testcase_05 AC 91 ms
71,460 KB
testcase_06 AC 93 ms
71,660 KB
testcase_07 AC 93 ms
71,704 KB
testcase_08 AC 97 ms
71,472 KB
testcase_09 AC 181 ms
79,428 KB
testcase_10 AC 155 ms
78,724 KB
testcase_11 AC 244 ms
81,384 KB
testcase_12 AC 378 ms
81,284 KB
testcase_13 AC 239 ms
80,124 KB
testcase_14 AC 823 ms
86,120 KB
testcase_15 AC 385 ms
81,164 KB
testcase_16 AC 988 ms
84,464 KB
testcase_17 AC 2,211 ms
90,240 KB
testcase_18 AC 2,028 ms
88,132 KB
testcase_19 AC 182 ms
79,712 KB
testcase_20 AC 176 ms
80,196 KB
testcase_21 AC 258 ms
81,892 KB
testcase_22 AC 409 ms
82,852 KB
testcase_23 AC 257 ms
81,540 KB
testcase_24 AC 3,972 ms
89,872 KB
testcase_25 AC 491 ms
83,092 KB
testcase_26 AC 1,071 ms
83,524 KB
testcase_27 TLE -
testcase_28 TLE -
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)
  def syokika(self,s,t):
    self.level=[-1]*self.v
    self.see=[0]*self.v
    for i in range(self.v):
      for j in range(len(self.G[i])):
        a,b,c=self.G[i][j]
        if b>i:
          self.G[i][j][0]=1
        else:
          self.G[i][j][0]=0
        if (i,b)==(s,t):
          self.G[i][j][0]=0
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.syokika(n,m)
  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