結果

問題 No.86 TVザッピング(2)
ユーザー 6soukiti296soukiti29
提出日時 2017-08-11 08:02:23
言語 Nim
(2.0.2)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,506 bytes
コンパイル時間 3,117 ms
コンパイル使用メモリ 68,212 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 14:03:31
合計ジャッジ時間 4,127 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 RE -
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils,strutils
var M,N : int
(M, N) = stdin.readline.split.map(parseInt)
var
    hyou = newSeq[string](M + 2,)
    D = [[1,0],[0,-1],[-1,0],[0,1]]
    cnt : int
    ans : bool
    cntd : int
    flag : array[102,array[102,int]]
    
hyou[0] = repeat('#',M + 2)
hyou[M + 1] = repeat('#',M + 2)

for n in 1..M:
    hyou[n] = '#' & stdin.readline & '#'




proc tansaku(i,j : int):bool=
    for d2 in 0..3:
        var
            x = i
            y = j
            cntf = 0
            cntf2 = 0
            nx,ny : int
        cnt += 1
        var d = d2
        while cntf <= cntd:
            nx = x + D[d][0]
            ny = y + D[d][1]
            if nx == i and ny == j and cntf == cntd - 1:
                return true
            elif hyou[ny][nx] == '.' and flag[ny][nx] < cnt:
                flag[ny][nx] = cnt
                cntf += 1
                x = nx
                y = ny
                cntf2 = 0
            elif cntf2 == 0:
                cntf2 += 1
                d = (d + 1) mod 4
            else:
                break
    return false
            
        
for x in 1..N:
    for y in 1..M:
        if hyou[y][x] == '.':
            cntd += 1

block tansaku:
    if cntd > 4 * (M + N):
        break tansaku
    for x in 1..N:
        for y in 1..M:
            if hyou[y][x] == '.':
                cnt += 10
                if tansaku(x,y):
                    ans = true
                    break tansaku
if ans:
    echo "YES"
else:
    echo "NO"
            
0