Submission #22481

#TimeUsernameProblemLanguageResultExecution timeMemory
22481- - - - - - - List of honorable mention follows - - - - - - - (#40)Young Zebra (KRIII5_YZ)Pypy 2
0 / 7
1044 ms101 KiB
r, c = map(int, raw_input().split()) data = [0] * r for i in range(r): data[i] = list(raw_input()) def getSzField(field): ret = [[-2 for i in range(len(field[0]))] for j in range(len(field))] movs = [(0, 1), (0, -1), (1, 0), (-1, 0)] for i in range(len(field)): for j in range(len(field[0])): if ret[i][j] == -2: q = [(i, j)] qi = 0 ret[i][j] = -3 while qi < len(q): y, x = q[qi] for mov in movs: ny = y + mov[0] nx = x + mov[1] if ny >= 0 and ny < len(field) and nx >= 0 and nx < len(field[0]) and field[ny][nx] == field[y][x] and ret[ny][nx] == -2: ret[ny][nx] = -3 q += [(ny, nx)] qi += 1 for coord in q: ret[coord[0]][coord[1]] = len(q) return ret sField = [[0 for j in range(3 * c)] for i in range(3 * r)] for i in range(3 * r): for j in range(3 * c): sField[i][j] = data[i % r][j % c] ssz = getSzField(sField) lField = [[0 for j in range(4 * c)] for i in range(4 * r)] for i in range(4 * r): for j in range(4 * c): lField[i][j] = data[i % r][j % c] lsz = getSzField(lField) for i in range(r): for j in range(c): if ssz[r + i][c + j] == lsz[r * 2 + i][c * 2 + j] and ssz[r + i][c + j] == lsz[r + i][c + j]: print ssz[r + i][c + j], else: print -1, print
#Verdict Execution timeMemoryGrader output
Fetching results...