結果
問題 | No.240 ナイト散歩 |
ユーザー |
|
提出日時 | 2016-08-11 19:38:07 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 838 bytes |
コンパイル時間 | 803 ms |
コンパイル使用メモリ | 111,380 KB |
実行使用メモリ | 26,020 KB |
最終ジャッジ日時 | 2024-10-07 21:27:42 |
合計ジャッジ時間 | 2,460 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;class Knight{static int gx, gy;static void Main(String[] arga){String[] vals = Console.ReadLine().Split(' ');gx = int.Parse(vals[0]);gy = int.Parse(vals[1]);if(KightWalk(0, 0, 0))Console.WriteLine("YES");elseConsole.WriteLine("NO");}static bool KightWalk(int x, int y, int steps){if(steps >= 4)return false;if(x == gx && y == gy)return true;if(KightWalk(x-2, y+1, steps+1))return true;if(KightWalk(x-2, y-1, steps+1))return true;if(KightWalk(x+2, y+1, steps+1))return true;if(KightWalk(x+2, y-1, steps+1))return true;if(KightWalk(x+1, y+2, steps+1))return true;if(KightWalk(x-1, y+2, steps+1))return true;if(KightWalk(x+1, y-2, steps+1))return true;if(KightWalk(x-1, y-2, steps+1))return true;return false;}}