結果

問題 No.455 冬の大三角
ユーザー yn
提出日時 2016-12-06 01:27:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 1,305 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 82,260 KB
実行使用メモリ 89,196 KB
最終ジャッジ日時 2024-06-29 21:06:30
合計ジャッジ時間 10,122 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54
権限があれば一括ダウンロードができます

ソースコード

diff #

import fractions
h, w = map(int,input().split())
s = [list(input()) for i in range(h)]

star = []

for j in range(h):
    for i in range(w):
        if s[j][i] == "*":
            star.append(j)
            star.append(i)
f = False
for j in range(h):
    for i in range(w):
        if s[j][i] == "*":
            continue
        if j == star[0] == star[2]:
            continue
        if i == star[1] == star[3]:
            continue
        if star[0] == star[2]:
            s[j][i] = "*"
            f = True
            break
        if star[1] == star[3]:
            s[j][i] = "*"
            f = True
            break

        if star[1] - star[3] != 0 and i - star[3] != 0  and \
            fractions.Fraction((star[0] - star[2]), (star[1] - star[3])) == \
            fractions.Fraction((j - star[2]), (i - star[3])):
            continue
        else:
            s[j][i] = "*"
            f = True
            break

        if star[0] - star[2] != 0 and j - star[2] != 0  and \
            fractions.Fraction((star[1] - star[3]), (star[0] - star[2])) == \
            fractions.Fraction((i - star[3]), (j - star[2])):
            continue
        else:
            s[j][i] = "*"
            f = True
            break
    if f:
        break

for j in range(h):
    print("".join(s[j][:]))
0