# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
22478 |
2017-04-30T04:59:19 Z |
- - - - - - - List of honorable mention follows - - - - - - -(#999, xhae, ainu7, littlesheep) |
Young Zebra (KRIII5_YZ) |
PyPy |
|
500 ms |
117 KB |
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))]
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 = [[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(5 * c)] for i in range(5 * r)]
for i in range(5 * r):
for j in range(5 * 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]:
print ssz[r + i][c + j],
else:
print -1,
print
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1091 ms |
117 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |