# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22499 | admin | Young Zebra (KRIII5_YZ) | Pypy 2 | 405 ms | 37 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
MOD = int(1e9 + 7)
import sys
sys.setrecursionlimit(10000000)
N, M = map(int, sys.stdin.readline().split())
S = ["" for _ in xrange(N)]
for i in xrange(N): S[i] = sys.stdin.readline().strip()
assert 1 <= N <= 400
assert 1 <= M <= 400
assert set(list("".join(S))).issubset(set(['B', 'W']))
assert all(len(line) == M for line in S)
visited = [[False for j in xrange(M)] for i in xrange(N)]
comp = [[0 for j in xrange(M)] for i in xrange(N)]
ans = [[-1 for j in xrange(M)] for i in xrange(N)]
pos = [[(0, 0) for j in xrange(M)] for i in xrange(N)]
num_components = 0
vertices = []
from collections import deque
def dfs (x, y, c):
que = deque([(x, y)])
que_len = 1
visited[x][y] = True
pos[x][y] = (x, y)
ret = 0
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |