結果

問題 No.179 塗り分け
ユーザー lllllll88938494lllllll88938494
提出日時 2023-05-10 23:13:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 192 ms / 3,000 ms
コード長 1,612 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 78,224 KB
最終ジャッジ日時 2023-08-18 01:14:42
合計ジャッジ時間 6,766 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,184 KB
testcase_01 AC 71 ms
71,284 KB
testcase_02 AC 72 ms
71,184 KB
testcase_03 AC 72 ms
71,188 KB
testcase_04 AC 71 ms
71,268 KB
testcase_05 AC 129 ms
77,488 KB
testcase_06 AC 74 ms
71,116 KB
testcase_07 AC 76 ms
75,912 KB
testcase_08 AC 101 ms
77,076 KB
testcase_09 AC 120 ms
77,348 KB
testcase_10 AC 80 ms
76,252 KB
testcase_11 AC 81 ms
76,032 KB
testcase_12 AC 144 ms
77,492 KB
testcase_13 AC 72 ms
71,264 KB
testcase_14 AC 76 ms
75,644 KB
testcase_15 AC 72 ms
71,272 KB
testcase_16 AC 73 ms
71,416 KB
testcase_17 AC 72 ms
71,264 KB
testcase_18 AC 86 ms
76,432 KB
testcase_19 AC 84 ms
76,200 KB
testcase_20 AC 136 ms
77,572 KB
testcase_21 AC 144 ms
77,632 KB
testcase_22 AC 192 ms
77,648 KB
testcase_23 AC 79 ms
76,008 KB
testcase_24 AC 133 ms
77,548 KB
testcase_25 AC 81 ms
76,140 KB
testcase_26 AC 117 ms
77,604 KB
testcase_27 AC 123 ms
77,676 KB
testcase_28 AC 112 ms
77,588 KB
testcase_29 AC 132 ms
77,932 KB
testcase_30 AC 124 ms
77,652 KB
testcase_31 AC 128 ms
77,440 KB
testcase_32 AC 98 ms
77,348 KB
testcase_33 AC 129 ms
77,948 KB
testcase_34 AC 116 ms
77,824 KB
testcase_35 AC 129 ms
78,224 KB
testcase_36 AC 72 ms
71,388 KB
testcase_37 AC 73 ms
71,404 KB
testcase_38 AC 73 ms
71,112 KB
testcase_39 AC 71 ms
71,308 KB
testcase_40 AC 72 ms
71,412 KB
testcase_41 AC 72 ms
71,256 KB
testcase_42 AC 72 ms
71,412 KB
testcase_43 AC 82 ms
75,608 KB
testcase_44 AC 91 ms
76,712 KB
testcase_45 AC 73 ms
71,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h,w=map(int,input().split())
g=[input() for i in range(h)]
cnt=0
for i in range(h):
    for j in range(w):
        if g[i][j] == '#':
            cnt+=1
if cnt ==0:
    print('NO')
    exit()
    
    

for xz in range(h):
    for yz in range(w):
        if 0 == xz and 0 == yz:
            continue
        f=[[0]*w for i in range(h)]
        ff=0
        for i in range(h):
            for j in range(w):
                if g[i][j] == '#' and f[i][j] == 0:                        
                    if i+xz >= h or j + yz >=w:
                        ff = 1
                        break
                    if g[i+xz][j+yz] != '#':
                        ff = 1
                        break
                    f[i+xz][j+yz] = 1
                    f[i][j] = 1
            if ff == 1:
                break

        if ff == 0:
            print('YES')
            exit()
            
for xz in range(h):
    for yz in range(w):
        if 0 == xz and 0 == yz:
            continue
        f=[[0]*w for i in range(h)]
        ff=0
        for i in range(h):
            for j in range(w):
                if g[i][j] == '#' and f[i][j] == 0:                        
                    if i+xz >= h or j - yz < 0:
                        ff = 1
                        break
                    if g[i+xz][j-yz] != '#':
                        ff = 1
                        break
                    f[i+xz][j-yz] = 1
                    f[i][j] = 1
            if ff == 1:
                break

        if ff == 0:
            print('YES')
            exit()

print('NO')
        
            
    
    
0