結果

問題 No.86 TVザッピング(2)
ユーザー yaoshimaxyaoshimax
提出日時 2015-03-01 22:26:29
言語 PyPy2
(7.3.13)
結果
AC  
実行時間 1,658 ms / 5,000 ms
コード長 1,366 bytes
コンパイル時間 2,065 ms
コンパイル使用メモリ 77,476 KB
実行使用メモリ 104,356 KB
最終ジャッジ日時 2023-08-26 15:00:36
合計ジャッジ時間 10,493 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
77,396 KB
testcase_01 AC 73 ms
78,624 KB
testcase_02 AC 74 ms
78,888 KB
testcase_03 AC 66 ms
76,356 KB
testcase_04 AC 67 ms
76,376 KB
testcase_05 AC 68 ms
76,364 KB
testcase_06 AC 66 ms
76,368 KB
testcase_07 AC 74 ms
78,948 KB
testcase_08 AC 75 ms
78,752 KB
testcase_09 AC 814 ms
95,472 KB
testcase_10 AC 1,399 ms
104,356 KB
testcase_11 AC 72 ms
78,484 KB
testcase_12 AC 67 ms
76,144 KB
testcase_13 AC 73 ms
79,180 KB
testcase_14 AC 97 ms
79,284 KB
testcase_15 AC 163 ms
80,308 KB
testcase_16 AC 163 ms
80,476 KB
testcase_17 AC 73 ms
78,912 KB
testcase_18 AC 84 ms
79,232 KB
testcase_19 AC 76 ms
78,960 KB
testcase_20 AC 80 ms
79,172 KB
testcase_21 AC 1,658 ms
99,828 KB
testcase_22 AC 73 ms
79,292 KB
testcase_23 AC 104 ms
79,264 KB
testcase_24 AC 73 ms
78,960 KB
testcase_25 AC 71 ms
76,496 KB
testcase_26 AC 70 ms
76,568 KB
testcase_27 AC 77 ms
76,412 KB
testcase_28 AC 79 ms
76,492 KB
testcase_29 AC 852 ms
95,996 KB
testcase_30 AC 70 ms
76,268 KB
testcase_31 AC 73 ms
78,932 KB
testcase_32 AC 75 ms
79,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,raw_input().split())
A=[raw_input() for i in range(N)]
dir=[(1,0),(0,1),(-1,0),(0,-1)]
cnt=0 
for i in range(N):
    for j in range(M):
        if A[i][j]=='.':
            cnt+=1
for i in range(N):
    for j in range(M):
        if A[i][j] =='.':
            for k in range(len(dir)):
                arrived=[[False for m in range(M)]for n in range(N)]
                a,b=i,j
                curCnt = 0
                arrived[a][b]=True
                #print (a,b),
                for d in range(6):
                    na,nb=a+dir[(k+d)%4][0],b+dir[(k+d)%4][1]
                    ok = False
                    while na<N and na >=0 and nb <M and nb>=0 and A[na][nb]=='.' and (arrived[na][nb]==False or (i== na and j==nb)):
                            curCnt+=1
                            #print (na,nb) ,
                            arrived[na][nb]=True
                            a=na
                            b=nb
                            ok=True
                            if a==i and b==j:
                                break
                            na,nb=a+dir[(k+d)%4][0],b+dir[(k+d)%4][1]
                    if ok == False or (a==i and b==j ):
                        break
                #print 
                if a==i and b==j and cnt == curCnt:
                    print "YES"
                    exit()
print "NO"


0