結果

問題 No.3679 なんかでっかい虫リターンズ
コンテスト
ユーザー 鳩でもわかるC#
提出日時 2026-09-06 13:43:40
言語 C#
(.NET 10.0.400 + ACL)
コンパイル:
dotnet_c
実行:
/usr/bin/dotnet_wrap
結果
AC  
実行時間 33 ms / 2,000 ms
+ 896µs
コード長 1,022 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,470 ms
コンパイル使用メモリ 173,256 KB
実行使用メモリ 195,976 KB
最終ジャッジ日時 2026-09-06 13:44:00
合計ジャッジ時間 11,755 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (84 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

class Program
{
    static (int a, int b) GetInput2()
    {
        int[] input = Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();
        return (input[0], input[1]);
    }
    static (int a, int b, int c, int d) GetInput4()
    {
        int[] input = Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();
        return (input[0], input[1], input[2], input[3]);
    }

    static void Main()
    {
        (int H, int W) = GetInput2();
        (int sr, int sc) = GetInput2();
        (int r1, int c1, int r2, int c2) = GetInput4();
        (int gr, int gc) = GetInput2();

        int ans = int.MaxValue;
        for (int r = r1; r <= r2; r++)
        {
            for (int c = c1; c <= c2; c++)
            {
                int d = Math.Abs(r - sr) + Math.Abs(c - sc);
                d += Math.Abs(gr - r) + Math.Abs(gc - c);
                d += Math.Abs(sr - gr) + Math.Abs(sc - gc);
                ans = Math.Min(ans, d);
            }
        }
        Console.WriteLine(ans);
    }
}
0