結果
問題 | No.240 ナイト散歩 |
ユーザー |
|
提出日時 | 2016-10-05 17:07:26 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 381 bytes |
コンパイル時間 | 140 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-07 21:30:32 |
合計ジャッジ時間 | 1,409 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
dx = [-2, -2, -1, -1, 1, 1, 2, 2]dy = [-1, 1, -2, 2, -2, 2, -1, 1]visited = set()stack = [(0, 0, 0)]while len(stack) > 0:x, y, d = stack.pop()visited.add((x, y))if d == 3:continuefor i in xrange(8):nx, ny = x+dx[i], y+dy[i]stack.append(((nx, ny, d+1)))print 'YES' if tuple(map(int, raw_input().split())) in visited else 'NO'