結果

問題 No.240 ナイト散歩
ユーザー nanophoto12nanophoto12
提出日時 2015-12-13 09:36:13
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 1,301 bytes
コンパイル時間 920 ms
コンパイル使用メモリ 114,244 KB
実行使用メモリ 28,524 KB
最終ジャッジ日時 2024-04-16 19:38:00
合計ジャッジ時間 3,006 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
26,208 KB
testcase_01 AC 33 ms
24,240 KB
testcase_02 AC 33 ms
28,460 KB
testcase_03 AC 33 ms
28,204 KB
testcase_04 AC 33 ms
28,512 KB
testcase_05 AC 33 ms
26,844 KB
testcase_06 AC 33 ms
24,244 KB
testcase_07 AC 33 ms
26,284 KB
testcase_08 AC 35 ms
26,420 KB
testcase_09 AC 33 ms
26,552 KB
testcase_10 AC 33 ms
26,668 KB
testcase_11 AC 32 ms
26,288 KB
testcase_12 AC 33 ms
26,600 KB
testcase_13 AC 33 ms
26,164 KB
testcase_14 AC 32 ms
26,548 KB
testcase_15 AC 32 ms
26,676 KB
testcase_16 AC 32 ms
26,672 KB
testcase_17 AC 32 ms
24,372 KB
testcase_18 AC 33 ms
26,340 KB
testcase_19 AC 32 ms
28,460 KB
testcase_20 AC 32 ms
26,416 KB
testcase_21 AC 31 ms
26,160 KB
testcase_22 AC 31 ms
26,592 KB
testcase_23 AC 32 ms
26,552 KB
testcase_24 AC 34 ms
26,352 KB
testcase_25 AC 33 ms
26,340 KB
testcase_26 AC 32 ms
26,424 KB
testcase_27 AC 32 ms
28,524 KB
testcase_28 AC 31 ms
26,540 KB
testcase_29 AC 33 ms
26,284 KB
testcase_30 AC 33 ms
26,156 KB
testcase_31 AC 32 ms
28,328 KB
testcase_32 AC 32 ms
26,292 KB
testcase_33 AC 33 ms
26,680 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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");
		}
	}
}
0