結果

問題 No.455 冬の大三角
ユーザー rpy3cpprpy3cpp
提出日時 2017-03-26 15:59:55
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 1,177 bytes
コンパイル時間 495 ms
コンパイル使用メモリ 10,892 KB
実行使用メモリ 8,436 KB
最終ジャッジ日時 2023-09-12 12:35:32
合計ジャッジ時間 4,421 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,304 KB
testcase_01 AC 16 ms
8,236 KB
testcase_02 AC 16 ms
8,260 KB
testcase_03 AC 17 ms
8,332 KB
testcase_04 AC 16 ms
8,288 KB
testcase_05 AC 16 ms
8,180 KB
testcase_06 AC 16 ms
8,248 KB
testcase_07 AC 16 ms
8,388 KB
testcase_08 AC 19 ms
8,436 KB
testcase_09 AC 17 ms
8,180 KB
testcase_10 AC 17 ms
8,172 KB
testcase_11 AC 16 ms
8,372 KB
testcase_12 AC 17 ms
8,284 KB
testcase_13 AC 16 ms
8,332 KB
testcase_14 AC 16 ms
8,332 KB
testcase_15 AC 16 ms
8,340 KB
testcase_16 AC 16 ms
8,252 KB
testcase_17 AC 16 ms
8,308 KB
testcase_18 AC 17 ms
8,260 KB
testcase_19 AC 16 ms
8,268 KB
testcase_20 AC 16 ms
8,212 KB
testcase_21 AC 16 ms
8,264 KB
testcase_22 AC 16 ms
8,260 KB
testcase_23 AC 17 ms
8,252 KB
testcase_24 AC 16 ms
8,264 KB
testcase_25 AC 16 ms
8,364 KB
testcase_26 AC 16 ms
8,232 KB
testcase_27 AC 15 ms
8,260 KB
testcase_28 AC 16 ms
8,176 KB
testcase_29 AC 18 ms
8,300 KB
testcase_30 AC 17 ms
8,380 KB
testcase_31 AC 16 ms
8,280 KB
testcase_32 AC 16 ms
8,244 KB
testcase_33 AC 18 ms
8,100 KB
testcase_34 AC 16 ms
8,284 KB
testcase_35 AC 17 ms
8,348 KB
testcase_36 AC 17 ms
8,372 KB
testcase_37 AC 16 ms
8,220 KB
testcase_38 AC 17 ms
8,316 KB
testcase_39 AC 18 ms
8,324 KB
testcase_40 AC 17 ms
8,292 KB
testcase_41 AC 18 ms
8,344 KB
testcase_42 AC 17 ms
8,336 KB
testcase_43 AC 16 ms
8,288 KB
testcase_44 AC 16 ms
8,364 KB
testcase_45 AC 18 ms
8,404 KB
testcase_46 AC 17 ms
8,336 KB
testcase_47 AC 17 ms
8,244 KB
testcase_48 AC 17 ms
8,188 KB
testcase_49 AC 16 ms
8,208 KB
testcase_50 AC 16 ms
8,336 KB
testcase_51 AC 16 ms
8,256 KB
testcase_52 AC 16 ms
8,424 KB
testcase_53 AC 16 ms
8,376 KB
testcase_54 AC 16 ms
8,292 KB
testcase_55 AC 16 ms
8,356 KB
testcase_56 AC 16 ms
8,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_data():
    H, W = map(int, input().split())
    Ss = [input().rstrip() for h in range(H)]
    return H, W, Ss

def solve(H, W, Ss):
    x1, y1, x2, y2 = get_star_pos(H, W, Ss)
    x3, y3 = put_star(H, W, x1, y1, x2, y2)
    print_stars(H, W, x1, y1, x2, y2, x3, y3)

def get_star_pos(H, W, Ss):
    xys = []
    for y, S in enumerate(Ss):
        for x, c in enumerate(S):
            if c == '*':
                xys.append(x)
                xys.append(y)
    return xys

def print_stars(H, W, x1, y1, x2, y2, x3, y3):
    star_pos = [(x1, y1), (x2, y2), (x3, y3)]
    for h in range(H):
        row = []
        for w in range(W):
            if (w, h) in star_pos:
                row.append('*')
            else:
                row.append('-')
        print(''.join(row))

def put_star(H, W, x1, y1, x2, y2):
    for x in range(W):
        for y in range(H):
            if is_valid(x1, y1, x2, y2, x, y):
                return x, y
    raise RuntimeError("Couldn't find star pos.")

def is_valid(x1, y1, x2, y2, x3, y3):
    x1 = x1 - x3
    x2 = x2 - x3
    y1 = y1 - y3
    y2 = y2 - y3
    return x1 * y2 != x2 * y1

H, W, Ss = read_data()
solve(H, W, Ss)
0