結果
問題 | No.421 しろくろチョコレート |
ユーザー | masa_aa |
提出日時 | 2021-05-21 00:49:04 |
言語 | PyPy3 (7.3.13) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,168 bytes |
コンパイル時間 | 373 ms |
コンパイル使用メモリ | 87,240 KB |
実行使用メモリ | 78,108 KB |
最終ジャッジ日時 | 2023-07-31 14:04:33 |
合計ジャッジ時間 | 8,094 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 69 ms
71,156 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 79 ms
75,832 KB |
testcase_08 | WA | - |
testcase_09 | AC | 72 ms
71,424 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 70 ms
71,424 KB |
testcase_13 | AC | 68 ms
71,040 KB |
testcase_14 | AC | 67 ms
71,256 KB |
testcase_15 | AC | 68 ms
71,412 KB |
testcase_16 | WA | - |
testcase_17 | AC | 108 ms
78,108 KB |
testcase_18 | AC | 105 ms
77,756 KB |
testcase_19 | AC | 70 ms
71,228 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 71 ms
71,232 KB |
testcase_24 | AC | 71 ms
71,116 KB |
testcase_25 | AC | 68 ms
71,036 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 84 ms
76,252 KB |
testcase_29 | AC | 89 ms
76,496 KB |
testcase_30 | AC | 87 ms
76,692 KB |
testcase_31 | AC | 89 ms
76,528 KB |
testcase_32 | WA | - |
testcase_33 | AC | 90 ms
76,444 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | AC | 102 ms
77,288 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | AC | 70 ms
71,200 KB |
testcase_42 | AC | 69 ms
71,304 KB |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | AC | 95 ms
77,400 KB |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | AC | 101 ms
77,760 KB |
testcase_52 | AC | 79 ms
76,448 KB |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | AC | 105 ms
77,752 KB |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | AC | 78 ms
76,288 KB |
ソースコード
class BipartiteMatching: def __init__(self, N, M): self.N = N self.M = M self.pairA = [-1] * N self.pairB = [-1] * M self.edge = [[] for _ in range(N)] self.was = [0] * N self.iter = 0 def add_edge(self, s, t): self.edge[s].append(t) def _DFS(self, s): self.was[s] = self.iter for t in self.edge[s]: if self.pairB[t] == -1: self.pairA[s] = t self.pairB[t] = s return True for t in self.edge[s]: if self.was[self.pairB[t]] != self.iter and self._DFS(self.pairB[t]): self.pairA[s] = t self.pairB[t] = s return True return False def bipartite_matching(self): res = 0 while True: self.iter += 1 found = 0 for i in range(self.N): if self.pairA[i] == -1 and self._DFS(i): found += 1 if not found: break res += found return res import sys input = sys.stdin.readline sys.setrecursionlimit(10000000) n, m = map(int, input().split()) s = [input() for _ in range(n)] bm = BipartiteMatching(n * m // 2 + 1, n * m // 2) b, w = 0, 0 for i in range(n): for j in range(m): if s[i][j] == ".": continue if s[i][j] == "b": b += 1 else: w += 1 if (i + j) % 2: if j < m - 1: if s[i][j + 1] != ".": bm.add_edge((i * m + j + 1) // 2, (i * m + j) // 2) if i < n - 1: if s[i + 1][j] != ".": bm.add_edge(((i + 1) * m + j) // 2, (i * m + j) // 2) else: if j < m - 1: if s[i][j + 1] != ".": bm.add_edge((i * m + j) // 2, (i * m + j + 1) // 2) if i < n - 1: if s[i + 1][j] != ".": bm.add_edge((i * m + j) // 2, ((i + 1) * m + j) // 2) match = bm.bipartite_matching() b -= match w -= match k = min(b, m) print(100 * match + 10 * k + (b + w - k - k))