結果

問題 No.179 塗り分け
ユーザー buey_tbuey_t
提出日時 2023-03-24 09:56:30
言語 PyPy3
(7.3.11)
結果
WA  
実行時間 -
コード長 2,579 bytes
コンパイル時間 392 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 88,144 KB
最終ジャッジ日時 2023-07-18 16:40:04
合計ジャッジ時間 18,868 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 239 ms
82,216 KB
testcase_01 AC 245 ms
82,332 KB
testcase_02 AC 247 ms
82,324 KB
testcase_03 AC 246 ms
82,576 KB
testcase_04 AC 243 ms
81,948 KB
testcase_05 AC 318 ms
85,056 KB
testcase_06 AC 245 ms
82,200 KB
testcase_07 AC 247 ms
82,368 KB
testcase_08 AC 531 ms
86,080 KB
testcase_09 WA -
testcase_10 AC 253 ms
83,832 KB
testcase_11 AC 251 ms
84,044 KB
testcase_12 AC 490 ms
85,016 KB
testcase_13 AC 246 ms
83,276 KB
testcase_14 AC 256 ms
83,664 KB
testcase_15 AC 238 ms
82,644 KB
testcase_16 AC 242 ms
82,368 KB
testcase_17 AC 237 ms
82,548 KB
testcase_18 AC 260 ms
83,628 KB
testcase_19 AC 263 ms
83,996 KB
testcase_20 AC 521 ms
85,704 KB
testcase_21 AC 527 ms
86,448 KB
testcase_22 AC 545 ms
86,496 KB
testcase_23 AC 251 ms
83,172 KB
testcase_24 AC 525 ms
86,224 KB
testcase_25 AC 266 ms
83,360 KB
testcase_26 WA -
testcase_27 AC 559 ms
86,528 KB
testcase_28 WA -
testcase_29 AC 542 ms
88,144 KB
testcase_30 WA -
testcase_31 AC 529 ms
86,608 KB
testcase_32 AC 330 ms
84,360 KB
testcase_33 AC 545 ms
85,720 KB
testcase_34 WA -
testcase_35 AC 565 ms
86,988 KB
testcase_36 AC 302 ms
82,008 KB
testcase_37 AC 256 ms
81,780 KB
testcase_38 AC 247 ms
82,456 KB
testcase_39 AC 241 ms
82,296 KB
testcase_40 AC 250 ms
83,412 KB
testcase_41 AC 244 ms
82,480 KB
testcase_42 AC 249 ms
82,488 KB
testcase_43 AC 275 ms
83,356 KB
testcase_44 AC 305 ms
83,888 KB
testcase_45 AC 260 ms
83,120 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
            
            for i in range(H):
                for j in range(W):
                    if T[i][j] == '#':
                        f = False
                        break
                else:
                    continue
                break
            
            if f:
                print('YES')
                exit()
    
    print('NO')
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0