結果

問題 No.179 塗り分け
ユーザー buey_tbuey_t
提出日時 2023-03-24 09:55:10
言語 PyPy3
(7.3.11)
結果
WA  
実行時間 -
コード長 2,324 bytes
コンパイル時間 849 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 87,256 KB
最終ジャッジ日時 2023-07-18 16:39:45
合計ジャッジ時間 19,813 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 244 ms
81,832 KB
testcase_01 AC 253 ms
82,344 KB
testcase_02 AC 250 ms
82,052 KB
testcase_03 AC 253 ms
82,584 KB
testcase_04 AC 250 ms
82,000 KB
testcase_05 AC 333 ms
84,816 KB
testcase_06 AC 251 ms
82,344 KB
testcase_07 AC 245 ms
82,372 KB
testcase_08 AC 523 ms
85,636 KB
testcase_09 WA -
testcase_10 AC 264 ms
83,264 KB
testcase_11 AC 261 ms
83,484 KB
testcase_12 AC 503 ms
85,908 KB
testcase_13 AC 260 ms
83,404 KB
testcase_14 AC 266 ms
83,544 KB
testcase_15 AC 246 ms
82,496 KB
testcase_16 AC 251 ms
82,248 KB
testcase_17 AC 245 ms
82,336 KB
testcase_18 AC 271 ms
83,564 KB
testcase_19 AC 274 ms
83,604 KB
testcase_20 AC 540 ms
87,256 KB
testcase_21 AC 546 ms
85,996 KB
testcase_22 AC 567 ms
86,248 KB
testcase_23 AC 252 ms
83,368 KB
testcase_24 AC 543 ms
85,712 KB
testcase_25 AC 262 ms
83,648 KB
testcase_26 WA -
testcase_27 AC 536 ms
86,064 KB
testcase_28 WA -
testcase_29 AC 560 ms
86,800 KB
testcase_30 WA -
testcase_31 AC 550 ms
86,004 KB
testcase_32 AC 346 ms
84,296 KB
testcase_33 AC 550 ms
85,908 KB
testcase_34 WA -
testcase_35 AC 557 ms
85,808 KB
testcase_36 AC 250 ms
82,592 KB
testcase_37 AC 252 ms
82,672 KB
testcase_38 AC 250 ms
82,560 KB
testcase_39 AC 249 ms
82,416 KB
testcase_40 AC 254 ms
82,988 KB
testcase_41 AC 251 ms
82,004 KB
testcase_42 AC 249 ms
82,504 KB
testcase_43 AC 275 ms
83,496 KB
testcase_44 AC 313 ms
83,776 KB
testcase_45 AC 270 ms
83,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
    from heapq import heapify, heappop, heappush
    from bisect import bisect_left, bisect_right
    from copy import deepcopy
    import copy
    import random
    from collections import deque,Counter,defaultdict
    from itertools import permutations,combinations
    from decimal import Decimal,ROUND_HALF_UP
    #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
    from functools import lru_cache, reduce
    #@lru_cache(maxsize=None)
    from operator import add,sub,mul,xor,and_,or_,itemgetter
    INF = 10**18
    mod1 = 10**9+7
    mod2 = 998244353
    
    #DecimalならPython
    
    
    '''
    H,Wが小さい
    4重ループまでは回る
    最左上を赤で塗るとして、そこからどう平行移動するのかを全探索する
    
    '''
    
    H,W = map(int, input().split())
    S = [list(input()) for _ in range(H)]
    
    sy = -1
    sx = -1
    
    for i in range(H):
        for j in range(W):
            if S[i][j] == '#':
                sy = i
                sx = j
                break
    
    if sy == -1:
        print('NO')
        exit()
    
    for dy in range(H):
        for dx in range(W):
            
            if dy == dx == 0:
                continue
            
            T = deepcopy(S)
            f = True
            
            for i in range(H):
                for j in range(W):
                    if T[i][j] == '#':
                        if i+dy>=H or j+dx>=W:
                            f = False
                            break
                        
                        if T[i+dy][j+dx] == '#':
                            T[i][j] = '.'
                            T[i+dy][j+dx] = '.'
                        else:
                            f = False
                            break
                
                else:
                    continue
                break
            
            if f:
                print('YES')
                exit()
    
    print('NO')
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0