Created
December 10, 2016 07:22
-
-
Save nariaki3551/a56c96ca25e45fdc6c750c95cbab9632 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ----------------------------------- | |
# yukicoder | |
# No.455 冬の大三角 | |
# http://yukicoder.me/problems/no/455 | |
# ------------------------------------ | |
# データ入力 | |
h, w = map(int, input().split()) | |
star_pos = dict() | |
count = 1 | |
sky = list() | |
for row in range(h): | |
s = input() | |
for i, elm in enumerate(s): | |
if elm == '*': | |
star_pos[count] = (row, i) | |
count += 1 | |
sky.append(list(s)) | |
# 星の追加候補は(0, 0), (1, 0), (0, 1)の3つ | |
if star_pos[1][0] == star_pos[2][0]: # 2星のy軸が同じ | |
if star_pos[1][0] != 0: | |
x, y = 0, 0 | |
else: | |
x, y = 0, 1 | |
elif star_pos[1][1] == star_pos[2][1]: # 2星のx軸が同じ | |
if star_pos[1][1] != 0: | |
x, y = 0, 0 | |
else: | |
x, y = 1, 0 | |
elif star_pos[1][1]*star_pos[2][0] == star_pos[2][1]*star_pos[1][0]: # 2星を結ぶ直線が(0, 0)を通る | |
x, y = 0, 1 | |
else: | |
x, y = 0, 0 | |
# 新しい星の追加 | |
sky[y][x] = '*' | |
for s in sky: | |
print(''.join(s)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment