結果

問題 No.455 冬の大三角
ユーザー rlangevinrlangevin
提出日時 2023-01-09 23:22:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 1,222 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 76,316 KB
最終ジャッジ日時 2023-08-22 22:15:23
合計ジャッジ時間 8,074 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,368 KB
testcase_01 AC 74 ms
71,460 KB
testcase_02 AC 75 ms
71,268 KB
testcase_03 AC 73 ms
71,284 KB
testcase_04 AC 72 ms
71,116 KB
testcase_05 AC 74 ms
71,036 KB
testcase_06 AC 73 ms
71,192 KB
testcase_07 AC 72 ms
71,220 KB
testcase_08 AC 77 ms
75,572 KB
testcase_09 AC 73 ms
71,088 KB
testcase_10 AC 71 ms
71,188 KB
testcase_11 AC 71 ms
70,976 KB
testcase_12 AC 72 ms
71,184 KB
testcase_13 AC 74 ms
71,340 KB
testcase_14 AC 73 ms
71,112 KB
testcase_15 AC 72 ms
71,292 KB
testcase_16 AC 72 ms
70,980 KB
testcase_17 AC 73 ms
71,092 KB
testcase_18 AC 73 ms
71,064 KB
testcase_19 AC 73 ms
71,092 KB
testcase_20 AC 73 ms
71,384 KB
testcase_21 AC 72 ms
71,400 KB
testcase_22 AC 72 ms
71,324 KB
testcase_23 AC 72 ms
71,396 KB
testcase_24 AC 73 ms
71,392 KB
testcase_25 AC 73 ms
71,384 KB
testcase_26 AC 74 ms
71,172 KB
testcase_27 AC 73 ms
71,320 KB
testcase_28 AC 73 ms
71,184 KB
testcase_29 AC 78 ms
75,764 KB
testcase_30 AC 78 ms
75,736 KB
testcase_31 AC 76 ms
75,620 KB
testcase_32 AC 78 ms
76,316 KB
testcase_33 AC 80 ms
75,404 KB
testcase_34 AC 74 ms
71,244 KB
testcase_35 AC 78 ms
75,400 KB
testcase_36 AC 77 ms
75,728 KB
testcase_37 AC 78 ms
75,616 KB
testcase_38 AC 78 ms
75,744 KB
testcase_39 AC 80 ms
75,800 KB
testcase_40 AC 78 ms
75,632 KB
testcase_41 AC 80 ms
75,760 KB
testcase_42 AC 79 ms
75,556 KB
testcase_43 AC 79 ms
75,980 KB
testcase_44 AC 77 ms
75,568 KB
testcase_45 AC 80 ms
75,656 KB
testcase_46 AC 81 ms
75,904 KB
testcase_47 AC 79 ms
75,764 KB
testcase_48 AC 79 ms
75,852 KB
testcase_49 AC 73 ms
71,248 KB
testcase_50 AC 72 ms
71,040 KB
testcase_51 AC 74 ms
71,236 KB
testcase_52 AC 74 ms
71,220 KB
testcase_53 AC 73 ms
70,988 KB
testcase_54 AC 74 ms
71,376 KB
testcase_55 AC 77 ms
75,476 KB
testcase_56 AC 75 ms
71,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def pprint(G):
    for g in G:
        print("".join(g))

from math import *

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

flag = 1
for i in range(H):
    for j in range(W):
        if G[i][j] == "*":
            if flag:
                x0, y0 = i, j
                flag = 0
            else:
                x1, y1 = i, j
                
for i in range(H):
    for j in range(W):
        if G[i][j] == "-":
            x, y = i, j
            dx0, dy0 = x - x0, y - y0
            dx1, dy1 = x - x1, y - y1
            if dx0 == 0 and dx1 == 0:
                continue
            if dy0 == 0 and dy1 == 0:
                continue
            if dx0 * dy0 * dx1 * dy1 == 0:
                G[i][j] = "*"
                pprint(G)
                exit()
            if dx0 < 0:
                dx0, dy0 = -dx0, -dy0
            if dx1 < 0:
                dx1, dy1 = -dx1, -dy1
            g0 = gcd(dx0, abs(dy0))
            g1 = gcd(dx1, abs(dy1))
            dx0 //= g0
            dy0 //= g0
            dx1 //= g1
            dy1 //= g1
            if (dx0, dy0) == (dx1, dy1):
                continue
            G[i][j] = "*"
            pprint(G)
            exit()
0