結果

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

ソースコード

diff #

def dfs(hp, hs):
	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)
	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) else "NO"
0