結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2015-12-13 09:36:13 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 33 ms / 2,000 ms |
コード長 | 1,301 bytes |
コンパイル時間 | 1,075 ms |
コンパイル使用メモリ | 112,908 KB |
実行使用メモリ | 28,644 KB |
最終ジャッジ日時 | 2024-10-07 21:16:33 |
合計ジャッジ時間 | 3,211 ms |
ジャッジサーバーID (参考情報) |
judge2 / 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; using System.Collections.Generic; using System.Linq; using System.Text; namespace No240 { class MainClass { public static void Main (string[] args) { var line = Console.ReadLine ().Split(' ').Select(value=>Convert.ToInt64(value)).ToArray(); var x = line [0]; var y = line [1]; HashSet<Tuple<long,long>> visited = new HashSet<Tuple<long, long>> (); visited.Add (new Tuple<long, long>(0, 0)); var steps = new [] { new Tuple<long,long> (2, 1), new Tuple<long,long> (2, -1), new Tuple<long,long> (-2, 1), new Tuple<long,long> (-2, -1), new Tuple<long,long> (1, 2), new Tuple<long,long> (1, -2), new Tuple<long,long> (-1, 2), new Tuple<long,long> (-1, -2), }; for (int i = 0; i < 3; i++) { HashSet<Tuple<long,long>> nextPositions = new HashSet<Tuple<long,long>> (visited); foreach (var element in visited) { foreach (var step in steps) { var next = new Tuple<long,long> (element.Item1 + step.Item1, element.Item2 + step.Item2); if (!nextPositions.Contains (next)) { nextPositions.Add (next); } } } visited = nextPositions; } if (visited.Contains (new Tuple<long,long> (x, y))) { Console.WriteLine ("YES"); return; } Console.WriteLine ("NO"); } } }