結果
| 問題 |
No.2213 Neq Move
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-17 23:51:52 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
AC
|
| 実行時間 | 62 ms / 2,000 ms |
| コード長 | 1,149 bytes |
| コンパイル時間 | 11,521 ms |
| コンパイル使用メモリ | 167,632 KB |
| 実行使用メモリ | 191,792 KB |
| 最終ジャッジ日時 | 2024-09-17 20:56:38 |
| 合計ジャッジ時間 | 11,987 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 5 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (94 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
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;
}
}