結果

問題 No.455 冬の大三角
ユーザー kichirb3
提出日時 2018-03-29 20:05:52
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 1,125 bytes
コンパイル時間 126 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-06-30 05:41:00
合計ジャッジ時間 3,411 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
"""
No.455 冬の大三角
https://yukicoder.me/problems/no/455

"""
import sys
from sys import stdin
input = stdin.readline


def solve(stars, fields, H, W):
    x1, y1 = stars[0][0], stars[0][1]
    x2, y2 = stars[1][0], stars[1][1]

    x0, y0 = 0, 0
    if x1 == x2:
        x0 = x1 - 1
        if x0 < 0:
            x0 = x1 + 1
        y0 = (y1 + y2) // 2
        while (x0 == x1 and y0 == y1) or (x0 == x2 and y0 == y2):
            y0 += 1
    else:
        y0 = y1 -1
        if y0 < 0:
            y0 = y1 + 1
        x0 = (x1 + x2) // 2
        while (x0 == x1 and y0 == y1) or (x0 == x2 and y0 == y2):
            x0 += 1

    fields[y0][x0] = '*'


def main(args):
    H, W = map(int, input().split())
    stars = []
    fields = [['-'] * W for _ in range(H)]
    for y in range(H):
        row = input().strip()
        for x, r in enumerate(row):
            if r == '*':
                stars.append([x, y])
                fields[y][x] = '*'

    ans = solve(stars, fields, H, W)

    for row in fields:
        print(*row, sep='')


if __name__ == '__main__':
    main(sys.argv[1:])
0