Submission #22455

#TimeUsernameProblemLanguageResultExecution timeMemory
22455- - - - - - - List of honorable mention follows - - - - - - - (#40)Young Zebra (KRIII5_YZ)Pypy 2
0 / 7
1058 ms85 KiB
r, c = map(int, raw_input().split()) data = [] for i in range(r): data += [list(raw_input())] def getSzField(field): ret = [[-2 for i in range(len(field[0]))] for j in range(len(field))] 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): movs = [(0, 1), (0, -1), (1, 0), (-1, 0)] 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 = [] for i in range(3 * r): sField += [[]] for j in range(3 * c): sField[i] += [data[i % r][j % c]] ssz = getSzField(sField) lField = [] for i in range(5 * r): lField += [[]] for j in range(5 * c): lField[i] += [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]: print ssz[r + i][c + j], else: print -1, print
#Verdict Execution timeMemoryGrader output
Fetching results...