結果

問題 No.455 冬の大三角
ユーザー shiccocsanshiccocsan
提出日時 2016-12-12 21:51:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 1,216 bytes
コンパイル時間 696 ms
コンパイル使用メモリ 11,144 KB
実行使用メモリ 9,004 KB
最終ジャッジ日時 2023-09-12 08:54:21
合計ジャッジ時間 4,305 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,948 KB
testcase_01 AC 19 ms
8,924 KB
testcase_02 AC 19 ms
8,940 KB
testcase_03 AC 19 ms
8,968 KB
testcase_04 AC 19 ms
8,848 KB
testcase_05 AC 19 ms
8,948 KB
testcase_06 AC 19 ms
8,892 KB
testcase_07 AC 19 ms
8,864 KB
testcase_08 AC 19 ms
8,988 KB
testcase_09 AC 19 ms
8,792 KB
testcase_10 AC 19 ms
8,868 KB
testcase_11 AC 19 ms
8,944 KB
testcase_12 AC 19 ms
8,804 KB
testcase_13 AC 19 ms
8,792 KB
testcase_14 AC 19 ms
8,924 KB
testcase_15 AC 19 ms
8,968 KB
testcase_16 AC 19 ms
8,864 KB
testcase_17 AC 19 ms
8,964 KB
testcase_18 AC 19 ms
8,944 KB
testcase_19 AC 19 ms
8,792 KB
testcase_20 AC 19 ms
8,936 KB
testcase_21 AC 20 ms
8,992 KB
testcase_22 AC 19 ms
8,792 KB
testcase_23 AC 19 ms
8,900 KB
testcase_24 AC 19 ms
8,944 KB
testcase_25 AC 19 ms
8,868 KB
testcase_26 AC 18 ms
8,932 KB
testcase_27 AC 19 ms
8,852 KB
testcase_28 AC 19 ms
8,968 KB
testcase_29 AC 19 ms
8,964 KB
testcase_30 AC 19 ms
8,924 KB
testcase_31 AC 19 ms
8,948 KB
testcase_32 AC 19 ms
8,916 KB
testcase_33 AC 19 ms
8,956 KB
testcase_34 AC 19 ms
8,872 KB
testcase_35 AC 20 ms
8,940 KB
testcase_36 AC 19 ms
8,812 KB
testcase_37 AC 19 ms
8,944 KB
testcase_38 AC 19 ms
8,812 KB
testcase_39 AC 19 ms
8,884 KB
testcase_40 AC 19 ms
8,816 KB
testcase_41 AC 19 ms
8,976 KB
testcase_42 AC 19 ms
8,924 KB
testcase_43 AC 20 ms
8,808 KB
testcase_44 AC 19 ms
8,936 KB
testcase_45 AC 19 ms
8,948 KB
testcase_46 AC 19 ms
8,944 KB
testcase_47 AC 19 ms
8,792 KB
testcase_48 AC 19 ms
9,004 KB
testcase_49 AC 19 ms
8,860 KB
testcase_50 AC 19 ms
8,804 KB
testcase_51 AC 19 ms
8,940 KB
testcase_52 AC 19 ms
8,952 KB
testcase_53 AC 19 ms
8,788 KB
testcase_54 AC 19 ms
8,980 KB
testcase_55 AC 20 ms
8,972 KB
testcase_56 AC 19 ms
8,868 KB
権限があれば一括ダウンロードができます

ソースコード

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):
        s = input()
        if len(stars) < 2:
            k = 0
            for j in range(2):
                f = s.find('*', k)
                if f >= 0:
                    stars.append((i, f))
                    k = f + 1
                else:
                    break

    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