結果
| 問題 |
No.421 しろくろチョコレート
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-05-12 22:13:36 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 666 bytes |
| コンパイル時間 | 458 ms |
| コンパイル使用メモリ | 82,080 KB |
| 実行使用メモリ | 67,920 KB |
| 最終ジャッジ日時 | 2025-05-12 22:13:44 |
| 合計ジャッジ時間 | 6,729 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 65 |
ソースコード
h, w = map(int, input().split())
A = [input() for _ in range(h)]
f = lambda x, y: x*w+y
g = lambda x: divmod(x, w)
from atcoder.maxflow import MFGraph
n = h*w+2
G = MFGraph(n)
st = n-2
ed = n-1
add = G.add_edge
cnt0 = 0
cnt1 = 0
for i in range(h):
for j in range(w):
if A[i][j]=='w':
add(st, f(i, j), 1)
cnt0 += 1
else:
if A[i][j]=='b':
add(f(i, j), ed, 1)
cnt1 += 1
continue
for di, dj in (0, 1), (1, 0), (-1, 0), (0, -1):
ni, nj = i+di, j+dj
if 0<=ni<h and 0<=nj<w and A[ni][nj]=='b':
add(f(i, j), f(ni, nj), 1)
t = G.flow(st, ed)
print(100*t + (min(cnt0, cnt1)-t)*10 + abs(cnt0-cnt1))