結果

問題 No.240 ナイト散歩
ユーザー TawaraTawara
提出日時 2015-07-19 14:40:53
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 364 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 6,696 KB
実行使用メモリ 6,060 KB
最終ジャッジ日時 2023-09-22 19:17:28
合計ジャッジ時間 2,193 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,944 KB
testcase_01 AC 11 ms
5,816 KB
testcase_02 AC 11 ms
5,900 KB
testcase_03 AC 11 ms
5,824 KB
testcase_04 AC 11 ms
5,900 KB
testcase_05 WA -
testcase_06 AC 11 ms
5,964 KB
testcase_07 AC 11 ms
5,880 KB
testcase_08 AC 11 ms
5,828 KB
testcase_09 AC 11 ms
5,896 KB
testcase_10 AC 12 ms
5,884 KB
testcase_11 AC 11 ms
5,936 KB
testcase_12 AC 11 ms
5,896 KB
testcase_13 AC 11 ms
5,816 KB
testcase_14 AC 12 ms
5,900 KB
testcase_15 AC 12 ms
5,884 KB
testcase_16 AC 11 ms
5,968 KB
testcase_17 AC 11 ms
5,948 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 11 ms
5,828 KB
testcase_21 AC 11 ms
5,884 KB
testcase_22 AC 11 ms
5,988 KB
testcase_23 AC 10 ms
5,868 KB
testcase_24 WA -
testcase_25 AC 10 ms
5,924 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 11 ms
5,828 KB
testcase_29 AC 11 ms
5,820 KB
testcase_30 AC 11 ms
5,816 KB
testcase_31 AC 11 ms
5,864 KB
testcase_32 AC 11 ms
5,820 KB
testcase_33 AC 10 ms
5,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def dfs(hp, hs):
	if hp == goal:
		return True
	ret = False
	for dx,dy in dxy:
		nxt = (hp[0]+dx, hp[1]+dy)
		if nxt not in visit and hs > 0:
			visit.add(nxt)
			ret |= dfs(nxt,hs-1)
	return ret
dxy = ((-2,-1),(-2,1),(-1,-2),(-1,2),(1,-2),(1,2),(2,-1),(2,1))
goal = tuple(map(int,raw_input().split(" ")))
visit = set([(0,0)])
print "YES" if dfs((0,0),3) else "NO"
0