結果

問題 No.240 ナイト散歩
ユーザー Tawara
提出日時 2015-07-19 15:03:39
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 375 bytes
コンパイル時間 40 ms
コンパイル使用メモリ 6,816 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-08 10:22:04
合計ジャッジ時間 1,108 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 25 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

def dfs(hp, hs, visit):
	visit.add(hp)
	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:
			ret |= dfs(nxt,hs-1, visit)
	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()
print "YES" if dfs((0,0),3,visit) else "NO"
0