結果

問題 No.2213 Neq Move
ユーザー 👑 kakel-sankakel-san
提出日時 2023-10-17 23:51:52
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 1,149 bytes
コンパイル時間 17,480 ms
コンパイル使用メモリ 159,924 KB
実行使用メモリ 177,224 KB
最終ジャッジ日時 2023-10-17 23:52:13
合計ジャッジ時間 11,632 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
32,492 KB
testcase_01 AC 82 ms
33,016 KB
testcase_02 AC 81 ms
33,152 KB
testcase_03 AC 82 ms
33,136 KB
testcase_04 AC 81 ms
33,132 KB
testcase_05 AC 82 ms
177,224 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (103 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var t = NN;
        var ans = new int[t];
        for (var u = 0; u < t; ++u)
        {
            var s = NList;
            ans[u] = Neq(s[0], s[1], s[2], s[3]);
        }
        WriteLine(string.Join("\n", ans));
    }
    static int Neq(int a, int b, int c, int d)
    {
        var ans = int.MaxValue;
        ans = Math.Min(ans, Move(a, b, c, d));
        ans = Math.Min(ans, Move(0, b, c, d) + 1);
        ans = Math.Min(ans, Move(a, 0, c, d) + 1);
        ans = Math.Min(ans, Move(0, 1, c, d) + (a == 1 ? 4 : 3));
        ans = Math.Min(ans, Move(1, 0, c, d) + (b == 1 ? 4 : 3));
        return ans;
    }
    static int Move(int a, int b, int c, int d)
    {
        if (a > c || b > d || (a < b != c < d)) return int.MaxValue - 5;
        return c - a + d - b;
    }
}
0