結果

問題 No.179 塗り分け
ユーザー buey_tbuey_t
提出日時 2023-03-24 09:56:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,579 bytes
コンパイル時間 1,529 ms
コンパイル使用メモリ 81,612 KB
実行使用メモリ 91,828 KB
最終ジャッジ日時 2023-10-18 19:58:44
合計ジャッジ時間 13,976 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
84,008 KB
testcase_01 AC 140 ms
88,124 KB
testcase_02 AC 128 ms
84,008 KB
testcase_03 AC 128 ms
84,004 KB
testcase_04 AC 137 ms
88,132 KB
testcase_05 AC 211 ms
89,376 KB
testcase_06 AC 140 ms
88,144 KB
testcase_07 AC 142 ms
88,364 KB
testcase_08 AC 451 ms
90,556 KB
testcase_09 WA -
testcase_10 AC 146 ms
88,936 KB
testcase_11 AC 147 ms
88,932 KB
testcase_12 AC 382 ms
90,924 KB
testcase_13 AC 154 ms
88,664 KB
testcase_14 AC 157 ms
88,880 KB
testcase_15 AC 138 ms
84,004 KB
testcase_16 AC 129 ms
84,008 KB
testcase_17 AC 128 ms
84,004 KB
testcase_18 AC 160 ms
89,020 KB
testcase_19 AC 158 ms
89,020 KB
testcase_20 AC 419 ms
91,500 KB
testcase_21 AC 451 ms
90,908 KB
testcase_22 AC 447 ms
90,544 KB
testcase_23 AC 149 ms
88,820 KB
testcase_24 AC 453 ms
90,716 KB
testcase_25 AC 158 ms
88,956 KB
testcase_26 WA -
testcase_27 AC 415 ms
90,536 KB
testcase_28 WA -
testcase_29 AC 445 ms
91,776 KB
testcase_30 WA -
testcase_31 AC 431 ms
90,600 KB
testcase_32 AC 233 ms
89,216 KB
testcase_33 AC 439 ms
91,268 KB
testcase_34 WA -
testcase_35 AC 434 ms
90,820 KB
testcase_36 AC 126 ms
84,008 KB
testcase_37 AC 140 ms
88,132 KB
testcase_38 AC 129 ms
84,012 KB
testcase_39 AC 129 ms
84,008 KB
testcase_40 AC 144 ms
88,668 KB
testcase_41 AC 128 ms
84,012 KB
testcase_42 AC 141 ms
88,132 KB
testcase_43 AC 165 ms
89,024 KB
testcase_44 AC 199 ms
89,080 KB
testcase_45 AC 153 ms
88,868 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