結果

問題 No.179 塗り分け
ユーザー buey_tbuey_t
提出日時 2023-03-24 10:03:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,317 ms / 3,000 ms
コード長 2,404 bytes
コンパイル時間 1,495 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 100,352 KB
最終ジャッジ日時 2023-10-18 19:59:37
合計ジャッジ時間 28,336 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 143 ms
88,340 KB
testcase_01 AC 145 ms
88,544 KB
testcase_02 AC 154 ms
89,112 KB
testcase_03 AC 147 ms
88,888 KB
testcase_04 AC 153 ms
89,076 KB
testcase_05 AC 325 ms
91,644 KB
testcase_06 AC 209 ms
90,016 KB
testcase_07 AC 144 ms
88,608 KB
testcase_08 AC 1,135 ms
96,648 KB
testcase_09 AC 1,269 ms
97,832 KB
testcase_10 AC 651 ms
92,968 KB
testcase_11 AC 595 ms
92,448 KB
testcase_12 AC 992 ms
95,652 KB
testcase_13 AC 166 ms
89,264 KB
testcase_14 AC 156 ms
89,116 KB
testcase_15 AC 128 ms
84,228 KB
testcase_16 AC 129 ms
84,236 KB
testcase_17 AC 131 ms
84,224 KB
testcase_18 AC 658 ms
92,820 KB
testcase_19 AC 640 ms
92,792 KB
testcase_20 AC 1,065 ms
95,836 KB
testcase_21 AC 1,221 ms
100,352 KB
testcase_22 AC 1,262 ms
98,908 KB
testcase_23 AC 670 ms
93,636 KB
testcase_24 AC 1,179 ms
97,172 KB
testcase_25 AC 671 ms
92,948 KB
testcase_26 AC 750 ms
93,676 KB
testcase_27 AC 1,317 ms
98,652 KB
testcase_28 AC 755 ms
93,468 KB
testcase_29 AC 1,166 ms
96,700 KB
testcase_30 AC 892 ms
96,676 KB
testcase_31 AC 1,159 ms
97,568 KB
testcase_32 AC 798 ms
93,760 KB
testcase_33 AC 1,126 ms
96,448 KB
testcase_34 AC 831 ms
93,888 KB
testcase_35 AC 1,126 ms
96,592 KB
testcase_36 AC 140 ms
88,356 KB
testcase_37 AC 143 ms
88,552 KB
testcase_38 AC 146 ms
88,880 KB
testcase_39 AC 149 ms
88,892 KB
testcase_40 AC 147 ms
88,892 KB
testcase_41 AC 144 ms
88,344 KB
testcase_42 AC 151 ms
88,896 KB
testcase_43 AC 205 ms
89,756 KB
testcase_44 AC 312 ms
89,780 KB
testcase_45 AC 194 ms
90,020 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,H):
        for dx in range(-W,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 i+dy<0 or j+dx>=W or j+dx<0:
                            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