結果

問題 No.179 塗り分け
ユーザー rlangevinrlangevin
提出日時 2023-01-22 12:45:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 338 ms / 3,000 ms
コード長 1,150 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 87,420 KB
実行使用メモリ 77,892 KB
最終ジャッジ日時 2023-09-06 23:28:12
合計ジャッジ時間 7,352 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,536 KB
testcase_01 AC 73 ms
71,204 KB
testcase_02 AC 71 ms
71,152 KB
testcase_03 AC 73 ms
71,116 KB
testcase_04 AC 77 ms
71,468 KB
testcase_05 AC 97 ms
76,636 KB
testcase_06 AC 72 ms
71,192 KB
testcase_07 AC 78 ms
76,028 KB
testcase_08 AC 78 ms
76,016 KB
testcase_09 AC 76 ms
76,208 KB
testcase_10 AC 80 ms
76,152 KB
testcase_11 AC 79 ms
76,196 KB
testcase_12 AC 338 ms
77,820 KB
testcase_13 AC 72 ms
71,252 KB
testcase_14 AC 73 ms
71,324 KB
testcase_15 AC 71 ms
71,356 KB
testcase_16 AC 73 ms
71,580 KB
testcase_17 AC 71 ms
71,152 KB
testcase_18 AC 98 ms
76,680 KB
testcase_19 AC 99 ms
76,844 KB
testcase_20 AC 182 ms
77,892 KB
testcase_21 AC 96 ms
76,644 KB
testcase_22 AC 100 ms
76,604 KB
testcase_23 AC 81 ms
76,180 KB
testcase_24 AC 95 ms
76,800 KB
testcase_25 AC 79 ms
75,904 KB
testcase_26 AC 83 ms
76,604 KB
testcase_27 AC 119 ms
77,848 KB
testcase_28 AC 92 ms
76,992 KB
testcase_29 AC 124 ms
77,612 KB
testcase_30 AC 125 ms
77,804 KB
testcase_31 AC 137 ms
77,720 KB
testcase_32 AC 117 ms
77,704 KB
testcase_33 AC 143 ms
77,752 KB
testcase_34 AC 108 ms
77,432 KB
testcase_35 AC 152 ms
77,640 KB
testcase_36 AC 72 ms
71,496 KB
testcase_37 AC 72 ms
71,372 KB
testcase_38 AC 73 ms
71,456 KB
testcase_39 AC 73 ms
71,452 KB
testcase_40 AC 70 ms
71,272 KB
testcase_41 AC 72 ms
71,324 KB
testcase_42 AC 71 ms
71,384 KB
testcase_43 AC 93 ms
76,640 KB
testcase_44 AC 99 ms
76,960 KB
testcase_45 AC 73 ms
71,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, input().split())
G = []
flag = 1
sx, sy = 0, 0
for i in range(H):
    G.append(list(input()))
    if flag:
        for j in range(W):
            if G[i][j] == "#":
                sx = i
                sy = j
                flag = 0
                break

s = (sx, sy)
for gx in range(H):
    for gy in range(W):
        g = (gx, gy)
        if G[gx][gy] != "#" or s == g:
            continue
        S = set()
        S.add(s)
        S.add(g)
        dx = g[0] - s[0]
        dy = g[1] - s[1]
        flag = 1
        for i in range(H):
            for j in range(W):
                if G[i][j] != "#":
                    continue
                if (i, j) in S:
                    continue
                nx = i + dx
                ny = j + dy
                if (nx, ny) in S:
                    continue
                if nx < 0 or nx > H - 1 or ny < 0 or ny > W - 1:
                    flag = 0
                    break
                if G[nx][ny] != "#":
                    flag = 0
                    break
                S.add((nx, ny))
        if flag:
            print("YES")
            exit()
print("NO")
0