結果

問題 No.179 塗り分け
ユーザー 百
提出日時 2023-04-16 14:41:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,847 ms / 3,000 ms
コード長 939 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-04-20 04:45:02
合計ジャッジ時間 11,524 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,880 KB
testcase_01 AC 35 ms
10,880 KB
testcase_02 AC 33 ms
10,880 KB
testcase_03 AC 43 ms
10,880 KB
testcase_04 AC 34 ms
10,880 KB
testcase_05 AC 31 ms
10,880 KB
testcase_06 AC 32 ms
11,008 KB
testcase_07 AC 34 ms
11,008 KB
testcase_08 AC 33 ms
11,008 KB
testcase_09 AC 28 ms
11,008 KB
testcase_10 AC 34 ms
11,136 KB
testcase_11 AC 34 ms
11,136 KB
testcase_12 AC 1,847 ms
11,008 KB
testcase_13 AC 33 ms
10,880 KB
testcase_14 AC 30 ms
10,752 KB
testcase_15 AC 33 ms
10,880 KB
testcase_16 AC 28 ms
10,880 KB
testcase_17 AC 31 ms
10,752 KB
testcase_18 AC 53 ms
11,008 KB
testcase_19 AC 53 ms
11,264 KB
testcase_20 AC 34 ms
11,008 KB
testcase_21 AC 33 ms
11,008 KB
testcase_22 AC 219 ms
11,008 KB
testcase_23 AC 29 ms
11,008 KB
testcase_24 AC 170 ms
11,008 KB
testcase_25 AC 36 ms
11,136 KB
testcase_26 AC 56 ms
11,008 KB
testcase_27 AC 657 ms
11,008 KB
testcase_28 AC 53 ms
11,136 KB
testcase_29 AC 977 ms
11,264 KB
testcase_30 AC 407 ms
11,136 KB
testcase_31 AC 1,198 ms
11,136 KB
testcase_32 AC 278 ms
11,008 KB
testcase_33 AC 1,234 ms
11,008 KB
testcase_34 AC 207 ms
11,136 KB
testcase_35 AC 1,413 ms
11,008 KB
testcase_36 AC 32 ms
10,880 KB
testcase_37 AC 32 ms
10,880 KB
testcase_38 AC 33 ms
10,752 KB
testcase_39 AC 32 ms
10,752 KB
testcase_40 AC 33 ms
10,880 KB
testcase_41 AC 28 ms
10,880 KB
testcase_42 AC 31 ms
10,880 KB
testcase_43 AC 54 ms
11,008 KB
testcase_44 AC 142 ms
11,008 KB
testcase_45 AC 35 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def res():
    import copy

    H,W=map(int,input().split())
    S=[[None] for _ in range(H)]

    for i in range(H):
        S[i]=list(input())

    b=[]
    for i in range(H):
        for j in range(W):
            if S[i][j]=='#':
                b.append([i,j])

    if (len(b)>1)and(len(b)%2==0):
        o=b[0]
        for i in b:
            if i==b[0]:
                continue
            l1=i[0]-o[0]
            l2=i[1]-o[1]
            t=copy.deepcopy(S)
            for j in b:
                if t[j[0]][j[1]]=='B':
                    if j==b[-1]:
                        return 'YES'
                    continue
                if (0<=(j[0]+l1)<H)and(0<=(j[1]+l2)<W):
                    if t[j[0]+l1][(j[1]+l2)]=='#':
                        t[j[0]+l1][(j[1]+l2)]='B'
                    else:
                        break
                else:
                    break
        return 'NO'
    return 'NO'

print(res())
0