結果

問題 No.455 冬の大三角
ユーザー shiccocsan
提出日時 2016-12-12 21:42:59
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 1,022 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-11-29 17:57:00
合計ジャッジ時間 4,097 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46 RE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

import random

m = 10 ** (-10)


def eq(a, b):
    return a - m <= b <= a + m


def p(stars, b):
    x1 = stars[0][0] - b[0]
    x2 = stars[1][0] - b[0]
    y1 = stars[0][1] - b[1]
    y2 = stars[1][1] - b[1]
    if (x1 == 0 and x2 == 0) or (y1 == 0 and y2 == 0):
        return True

    if x2 == 0:
        x1, x2 = x2, x1
        y1, y2 = y2, y1
    if y2 == 0:
        return False
    return eq(x1 / x2, y1 / y2)


def run():
    H, W = list(map(int, input().split()))
    stars = []
    for i in range(H):
        f = input().find('*')
        if f >= 0:
            stars.append((i, f))

    while 1:
        star3 = (random.randint(0, H - 1), random.randint(0, W - 1))
        if star3 not in stars and not p(stars, star3):
            stars.append(star3)
            break

    for i in range(H):
        row = '-' * W
        for a in [s for s in stars if s[0] == i]:
            row = row[:a[1]] + '*' + (row[a[1] + 1:] if a[1] < W - 1 else '')

        print(row)


run()
# print(p(((0, 1), (1, 4)), (3, 10)))
0