import sequtils template times*(n:int,body) = (for _ in 0..= 0 : if used[match[dst]] : continue if not B.dfs(match[dst]) : continue match[src] = dst match[dst] = src return true return false for src in 0..= 0 : continue used = newSeq[false](B.len) if B.dfs(src) : result += 1 proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "" .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': return result = 10 * result + k.ord - '0'.ord let h = scan() let w = scan() proc encode(x,y:int):int = x * h + y let n = h * w var C = newSeqWith(w,newSeqWith(h,'.')) for y in 0..= w or ny >= h : continue if C[nx][ny] == '.' : continue F.add(encode(x,y),encode(nx,ny)) var ans = F.bipartiteMatching() wSum -= ans bSum -= ans ans *= 100 let pair = min(bSum,wSum) ans = ans + 10 * pair wSum -= pair bSum -= pair echo ans + wSum + bSum