結果

問題 No.455 冬の大三角
ユーザー maguroguma
提出日時 2017-08-27 15:44:32
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 1,290 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-06-30 03:05:49
合計ジャッジ時間 4,270 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(input())

# 2つの見つかった星の座標を取得
stars = []
for i in range(H):
    for j in range(W):
        if S[i][j] == '*':
            stars.append((j,i)) # 座標に注意

A = stars[0]
B = stars[1]
C = None
if A[0] == B[0]:
    # 星Aと星Bのx座標が等しい場合,Wの範囲内で異なるx座標を取った星の座標を選べば良い
    for x in range(W):
        if x != A[0]:
            C = (x,0)   # y座標は適当
            break
else:
    if A[1] == B[1]:
        # y座標が等しい場合,Hの範囲内で異なるy座標を取った星の座標を選べば良い
        for y in range(H):
            if y != A[1]:
                C = (0,y) # x座標は適当
                break
    else:
        # x座標もy座標も異なる場合は,それぞれのx座標とy座標を採用することで直角三角形を作れる
        C = (A[0], B[1])

'''
if C == None:
    print('error!')
else:
    print(C)
'''

# SのC座標を*で書き換える
temp = S[C[1]]
temp = list(temp)
temp[C[0]] = '*'
temp = ''.join(temp)
S[C[1]] = temp
# 描画
for i in range(H):
    for j in range(W):
        print(S[i][j], end='') if j<W-1 else print(S[i][j])
0