結果

問題 No.179 塗り分け
ユーザー brthyyjpbrthyyjp
提出日時 2021-06-29 02:43:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 192 ms / 3,000 ms
コード長 949 bytes
コンパイル時間 396 ms
コンパイル使用メモリ 86,796 KB
実行使用メモリ 78,016 KB
最終ジャッジ日時 2023-09-08 00:08:58
合計ジャッジ時間 6,990 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,320 KB
testcase_01 AC 68 ms
71,144 KB
testcase_02 AC 68 ms
70,960 KB
testcase_03 AC 69 ms
70,924 KB
testcase_04 AC 69 ms
71,476 KB
testcase_05 AC 115 ms
77,012 KB
testcase_06 AC 76 ms
76,000 KB
testcase_07 AC 68 ms
71,236 KB
testcase_08 AC 187 ms
77,544 KB
testcase_09 AC 190 ms
77,340 KB
testcase_10 AC 81 ms
76,344 KB
testcase_11 AC 81 ms
76,440 KB
testcase_12 AC 168 ms
77,648 KB
testcase_13 AC 72 ms
71,028 KB
testcase_14 AC 77 ms
76,008 KB
testcase_15 AC 69 ms
71,024 KB
testcase_16 AC 68 ms
71,144 KB
testcase_17 AC 70 ms
71,276 KB
testcase_18 AC 108 ms
77,436 KB
testcase_19 AC 107 ms
77,644 KB
testcase_20 AC 175 ms
77,444 KB
testcase_21 AC 179 ms
77,432 KB
testcase_22 AC 192 ms
77,388 KB
testcase_23 AC 82 ms
76,416 KB
testcase_24 AC 191 ms
77,476 KB
testcase_25 AC 86 ms
76,540 KB
testcase_26 AC 118 ms
77,468 KB
testcase_27 AC 157 ms
77,584 KB
testcase_28 AC 112 ms
77,224 KB
testcase_29 AC 153 ms
77,436 KB
testcase_30 AC 125 ms
77,548 KB
testcase_31 AC 153 ms
77,292 KB
testcase_32 AC 125 ms
77,432 KB
testcase_33 AC 154 ms
77,352 KB
testcase_34 AC 144 ms
78,016 KB
testcase_35 AC 153 ms
77,436 KB
testcase_36 AC 71 ms
71,132 KB
testcase_37 AC 69 ms
71,372 KB
testcase_38 AC 67 ms
71,128 KB
testcase_39 AC 67 ms
71,136 KB
testcase_40 AC 68 ms
71,448 KB
testcase_41 AC 68 ms
71,356 KB
testcase_42 AC 68 ms
71,200 KB
testcase_43 AC 105 ms
77,208 KB
testcase_44 AC 111 ms
77,200 KB
testcase_45 AC 80 ms
76,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w = map(int, input().split())
S = [input() for i in range(h)]

cnt = 0
for i in range(h):
    cnt += S[i].count('#')

if cnt == 0:
    print('NO')
    exit()

for di in range(h):
    for dj in range(-(w-1), w):
        if di == 0 and dj == 0:
            continue
        C = [[-1]*w for i in range(h)]
        flag = True
        for i in range(h):
            for j in range(w):
                if S[i][j] == '#' and C[i][j] == -1:
                    C[i][j] = 0
                    ni, nj = i+di, j+dj
                    if 0 <= ni < h and 0 <= nj < w:
                        if S[ni][nj] == '#' and C[ni][nj] == -1:
                            C[ni][nj] = 1
                        else:
                            flag = False
                            break
                    else:
                        flag = False
                        break
        if flag:
            print('YES')
            exit()
else:
    print('NO')
0