結果
問題 | No.240 ナイト散歩 |
ユーザー | nuwasogi |
提出日時 | 2015-11-28 23:57:24 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,863 bytes |
コンパイル時間 | 3,069 ms |
コンパイル使用メモリ | 114,028 KB |
実行使用メモリ | 27,476 KB |
最終ジャッジ日時 | 2024-09-14 05:00:56 |
合計ジャッジ時間 | 5,142 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 30 ms
27,280 KB |
testcase_01 | AC | 30 ms
25,120 KB |
testcase_02 | AC | 33 ms
25,396 KB |
testcase_03 | AC | 30 ms
24,988 KB |
testcase_04 | AC | 30 ms
25,008 KB |
testcase_05 | AC | 34 ms
27,316 KB |
testcase_06 | AC | 30 ms
24,756 KB |
testcase_07 | AC | 29 ms
25,008 KB |
testcase_08 | AC | 29 ms
25,104 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 30 ms
24,996 KB |
testcase_13 | AC | 30 ms
25,228 KB |
testcase_14 | WA | - |
testcase_15 | AC | 30 ms
27,040 KB |
testcase_16 | AC | 30 ms
25,104 KB |
testcase_17 | WA | - |
testcase_18 | AC | 30 ms
25,004 KB |
testcase_19 | AC | 33 ms
27,284 KB |
testcase_20 | AC | 32 ms
25,124 KB |
testcase_21 | AC | 29 ms
24,868 KB |
testcase_22 | AC | 32 ms
25,248 KB |
testcase_23 | AC | 32 ms
25,376 KB |
testcase_24 | AC | 32 ms
27,336 KB |
testcase_25 | AC | 33 ms
25,120 KB |
testcase_26 | AC | 33 ms
25,252 KB |
testcase_27 | AC | 33 ms
25,388 KB |
testcase_28 | AC | 29 ms
27,156 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; namespace KnightSanpo_CS { class Program { static void Main(string[] args) { Solution mysol = new Solution(); if (mysol.Solve()) Console.WriteLine("YES"); else Console.WriteLine("NO"); } } class Solution { static Vector[] Moves = { new Vector(1, 2), new Vector(2, 1), new Vector(2, -1), new Vector(1, -2), new Vector(-1, -2), new Vector(-2, -1), new Vector(-2, 1), new Vector(-1, 2) }; Vector Destination; static int SDThreshold = 45; public bool Solve() { if (Destination.SquareDistance > SDThreshold) { return false; } else if (Destination.SquareDistance <= 1 || Destination.SquareDistance == 5 || Destination.SquareDistance == 20 || Destination.SquareDistance == SDThreshold) { return true; } else { Queue<Vector> q = new Queue<Vector>(); q.Enqueue(new Vector(0, 0)); while (q.Count() != 0) { Vector loc = q.Dequeue(); if (loc.n >= 4) return false; foreach (Vector m in Moves) { Vector moved = loc + m; if (moved == Destination) { return true; } else { moved.n++; if (!q.Contains(moved)) { q.Enqueue(moved); } } } } return false; } } public Solution() { int[] xy = ria(); Destination = new Vector(xy[0], xy[1]); } static String rs() { return Console.ReadLine(); } static int ri() { return int.Parse(Console.ReadLine()); } static long rl() { return long.Parse(Console.ReadLine()); } static double rd() { return double.Parse(Console.ReadLine()); } static String[] rsa() { return Console.ReadLine().Split(' '); } static int[] ria() { return Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray(); } static long[] rla() { return Console.ReadLine().Split(' ').Select(e => long.Parse(e)).ToArray(); } static double[] rda() { return Console.ReadLine().Split(' ').Select(e => double.Parse(e)).ToArray(); } } struct Vector { public int X, Y; public int n; public Vector(int x, int y) { X = x; Y = y; n = 0; } public Vector(Vector a) { X = a.X; Y = a.Y; n = a.n; } public static Vector operator +(Vector a, Vector b) { Vector c = new Vector(a.X + b.X, a.Y + b.Y); return c; } public static Vector operator -(Vector a, Vector b) { Vector c = new Vector(a.X - b.X, a.Y - b.Y); return c; } public static Vector operator -(Vector a) { Vector c = new Vector(-a.X, -a.Y); return c; } public static bool operator ==(Vector a, Vector b) { return (a.X == b.X && a.Y == b.Y); } public static bool operator !=(Vector a, Vector b) { return (a.X != b.X || a.Y != b.Y); } public int SquareDistance { get { return (X * X + Y * Y); } } } }