結果
| 問題 | No.1412 Super Ryuo |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-10 12:36:25 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,792 bytes |
| 記録 | |
| コンパイル時間 | 7,669 ms |
| コンパイル使用メモリ | 169,520 KB |
| 実行使用メモリ | 187,288 KB |
| 最終ジャッジ日時 | 2025-12-10 12:36:34 |
| 合計ジャッジ時間 | 9,451 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 WA * 4 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (99 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System;
class Program
{
static void Main()
{
var s = Console.ReadLine().Split();
long x1 = long.Parse(s[0]);
long y1 = long.Parse(s[1]);
long x2 = long.Parse(s[2]);
long y2 = long.Parse(s[3]);
long dx = Math.Abs(x1 - x2);
long dy = Math.Abs(y1 - y2);
if (dx == 0 && dy == 0)
{
Console.WriteLine(0);
return;
}
// 1手で行ける
if (dx == 0 || dy == 0) // 飛車
{
Console.WriteLine(1);
return;
}
if (dx + dy <= 2) // マンハッタン距離2以内
{
Console.WriteLine(1);
return;
}
// 2手で行ける条件
// 小移動 → 飛車
// つまり (x1+a == x2) または (y1+b == y2) となる a,b で |a|+|b|<=2 が存在するか
// ⇔ |x1 - x2| <= 2 または |y1 - y2| <= 2
if (dx <= 2 || dy <= 2)
{
Console.WriteLine(2);
return;
}
// 小移動2回 → マンハッタン距離4以内
if (dx + dy <= 4)
{
Console.WriteLine(2);
return;
}
// 飛車 → 小移動
// 1手目で x = x2 の任意の高さに行けるので、そこで小移動で y2 に近づく:
// 必要距離 = |y1 - y2| <= 2
if (Math.Abs(y1 - y2) <= 2)
{
Console.WriteLine(2);
return;
}
// y = y2 に飛んでから小移動:
if (Math.Abs(x1 - x2) <= 2)
{
Console.WriteLine(2);
return;
}
// どれにも当てはまらないなら最大3手
Console.WriteLine(3);
}
}