結果

問題 No.455 冬の大三角
ユーザー はむ吉🐹
提出日時 2016-12-06 22:37:30
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 840 bytes
コンパイル時間 72 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-06-29 21:16:09
合計ジャッジ時間 3,293 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3

import itertools
import random


EPS = 1e-10


def outer_product(v1, v2):
    return v1.real * v2.imag - v1.imag * v2.real


def main():
    h, w = (int(x) for x in input().split())
    is_occupied = [[c == "*" for c in input()] for _ in range(h)]
    s1, s2 = (complex(r, c) for r, c in itertools.product(range(h), range(w))
              if is_occupied[r][c])
    ans = None
    for r, c in itertools.product(range(h), range(w)):
        if is_occupied[r][c]:
            continue
        else:
            s3 = complex(r, c)
            if abs(outer_product(s3 - s1, s3 - s2)) > EPS:
                ans = (r, c)
                break
    is_occupied[ans[0]][ans[1]] = True
    g = ("".join("*" if x else "-" for x in line) for line in is_occupied)
    print(*g, sep="\n")


if __name__ == '__main__':
    main()
0