結果
| 問題 | 
                            No.240 ナイト散歩
                             | 
                    
| コンテスト | |
| ユーザー | 
                             poapoa
                         | 
                    
| 提出日時 | 2020-08-28 01:45:43 | 
| 言語 | Nim  (2.2.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 575 bytes | 
| コンパイル時間 | 4,387 ms | 
| コンパイル使用メモリ | 66,304 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-09 00:58:26 | 
| 合計ジャッジ時間 | 5,653 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 30 | 
ソースコード
import strutils
import sequtils
import deques
var
    xs  = stdin.readLine.split.map(parseInt)
    z   = (xs[0], xs[1])
    q   = initDeque[(int, int)]()
    ans = "NO"
q.addLast((0, 0))
while true:
  var ite = q.popFirst
  var (x0, y0) = ite
  if x0 <= -8:
    ans = "NO"
    break
  if ite == z:
    ans = "YES"
    break
  q.addLast((x0 - 2, y0 - 1))
  q.addLast((x0 - 2, y0 + 1))
  q.addLast((x0 - 1, y0 - 2))
  q.addLast((x0 - 1, y0 + 2))
  q.addLast((x0 + 1, y0 - 2))
  q.addLast((x0 + 1, y0 + 2))
  q.addLast((x0 + 2, y0 - 1))
  q.addLast((x0 + 2, y0 + 1))
echo ans
            
            
            
        
            
poapoa