結果

問題 No.179 塗り分け
ユーザー titiatitia
提出日時 2022-05-05 00:33:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,737 ms / 3,000 ms
コード長 1,332 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 8,408 KB
最終ジャッジ日時 2023-09-17 05:51:12
合計ジャッジ時間 6,658 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,096 KB
testcase_01 AC 18 ms
7,824 KB
testcase_02 AC 17 ms
8,244 KB
testcase_03 AC 17 ms
8,176 KB
testcase_04 AC 16 ms
8,260 KB
testcase_05 AC 35 ms
8,312 KB
testcase_06 AC 16 ms
8,272 KB
testcase_07 AC 1,737 ms
8,188 KB
testcase_08 AC 53 ms
8,248 KB
testcase_09 AC 105 ms
8,268 KB
testcase_10 AC 18 ms
8,276 KB
testcase_11 AC 17 ms
8,292 KB
testcase_12 AC 295 ms
8,288 KB
testcase_13 AC 17 ms
8,308 KB
testcase_14 AC 17 ms
8,264 KB
testcase_15 AC 16 ms
8,272 KB
testcase_16 AC 16 ms
8,228 KB
testcase_17 AC 17 ms
8,296 KB
testcase_18 AC 19 ms
8,236 KB
testcase_19 AC 18 ms
8,288 KB
testcase_20 AC 145 ms
8,188 KB
testcase_21 AC 272 ms
8,256 KB
testcase_22 AC 758 ms
8,304 KB
testcase_23 AC 17 ms
8,144 KB
testcase_24 AC 144 ms
8,256 KB
testcase_25 AC 17 ms
8,376 KB
testcase_26 AC 68 ms
8,256 KB
testcase_27 AC 101 ms
8,268 KB
testcase_28 AC 63 ms
8,260 KB
testcase_29 AC 98 ms
8,240 KB
testcase_30 AC 77 ms
8,300 KB
testcase_31 AC 101 ms
8,408 KB
testcase_32 AC 29 ms
8,332 KB
testcase_33 AC 107 ms
8,284 KB
testcase_34 AC 68 ms
8,364 KB
testcase_35 AC 108 ms
8,372 KB
testcase_36 AC 16 ms
8,200 KB
testcase_37 AC 17 ms
7,704 KB
testcase_38 AC 16 ms
8,204 KB
testcase_39 AC 17 ms
8,268 KB
testcase_40 AC 16 ms
8,096 KB
testcase_41 AC 16 ms
8,292 KB
testcase_42 AC 16 ms
7,864 KB
testcase_43 AC 21 ms
8,208 KB
testcase_44 AC 31 ms
8,236 KB
testcase_45 AC 17 ms
8,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W=map(int,input().split())
MAP=[input().strip() for i in range(H)]

for i in range(H):
    for j in range(W):
        S=[[0]*W for i in range(H)]

        flag=0
        count=0

        for k in range(H):
            if flag==1:
                break
            for l in range(W):
                if MAP[k][l]=="#" and S[k][l]==0:
                    S[k][l]=1
                    count+=1
                    if k+i<H and j+l<W and MAP[k+i][j+l]=="#" and S[k+i][j+l]==0:
                        S[k+i][j+l]=2
                    else:
                        flag=1
                        break

        if flag==0 and count>0:
            print("YES")
            exit()

for i in range(H):
    for j in range(W):
        S=[[0]*W for i in range(H)]

        flag=0
        count=0

        for k in range(H):
            if flag==1:
                break
            for l in range(W-1,-1,-1):
                if MAP[k][l]=="#" and S[k][l]==0:
                    S[k][l]=1
                    count+=1
                    if k+i<H and 0<=l-j<W and MAP[k+i][l-j]=="#" and S[k+i][l-j]==0:
                        S[k+i][l-j]=2
                    else:
                        flag=1
                        break

        if flag==0 and count>0:
            print("YES")
            exit()

print("NO")
                    
0