結果

問題 No.179 塗り分け
ユーザー 百
提出日時 2023-04-16 14:41:32
言語 Python3
(3.11.2 + numpy 1.24.2 + scipy 1.10.1)
結果
AC  
実行時間 1,733 ms / 3,000 ms
コード長 939 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 10,952 KB
実行使用メモリ 8,764 KB
最終ジャッジ日時 2023-08-02 04:38:45
合計ジャッジ時間 13,550 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,436 KB
testcase_01 AC 18 ms
8,412 KB
testcase_02 AC 19 ms
8,436 KB
testcase_03 AC 18 ms
8,420 KB
testcase_04 AC 19 ms
8,440 KB
testcase_05 AC 19 ms
8,480 KB
testcase_06 AC 19 ms
8,420 KB
testcase_07 AC 19 ms
8,460 KB
testcase_08 AC 20 ms
8,484 KB
testcase_09 AC 20 ms
8,628 KB
testcase_10 AC 22 ms
8,676 KB
testcase_11 AC 21 ms
8,720 KB
testcase_12 AC 1,733 ms
8,652 KB
testcase_13 AC 20 ms
8,460 KB
testcase_14 AC 20 ms
8,528 KB
testcase_15 AC 18 ms
8,512 KB
testcase_16 AC 19 ms
8,436 KB
testcase_17 AC 19 ms
8,556 KB
testcase_18 AC 40 ms
8,672 KB
testcase_19 AC 38 ms
8,548 KB
testcase_20 AC 19 ms
8,532 KB
testcase_21 AC 19 ms
8,476 KB
testcase_22 AC 207 ms
8,608 KB
testcase_23 AC 20 ms
8,628 KB
testcase_24 AC 148 ms
8,520 KB
testcase_25 AC 24 ms
8,608 KB
testcase_26 AC 39 ms
8,484 KB
testcase_27 AC 617 ms
8,608 KB
testcase_28 AC 40 ms
8,580 KB
testcase_29 AC 936 ms
8,688 KB
testcase_30 AC 376 ms
8,644 KB
testcase_31 AC 1,159 ms
8,764 KB
testcase_32 AC 252 ms
8,704 KB
testcase_33 AC 1,167 ms
8,624 KB
testcase_34 AC 184 ms
8,600 KB
testcase_35 AC 1,354 ms
8,712 KB
testcase_36 AC 19 ms
8,480 KB
testcase_37 AC 19 ms
8,560 KB
testcase_38 AC 19 ms
8,376 KB
testcase_39 AC 18 ms
8,384 KB
testcase_40 AC 19 ms
8,428 KB
testcase_41 AC 19 ms
8,400 KB
testcase_42 AC 20 ms
8,412 KB
testcase_43 AC 39 ms
8,464 KB
testcase_44 AC 128 ms
8,512 KB
testcase_45 AC 22 ms
8,496 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