답안 #22455

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
22455 2017-04-30T04:50:34 Z - - - - - - - List of honorable mention follows - - - - - - -(#999, xhae, ainu7, littlesheep) Young Zebra (KRIII5_YZ) PyPy
0 / 7
500 ms 85 KB
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
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1058 ms 85 KB Time limit exceeded
2 Halted 0 ms 0 KB -