結果
問題 | No.2771 Personal Space |
ユーザー |
|
提出日時 | 2024-05-31 22:32:32 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 575 ms / 2,000 ms |
コード長 | 2,308 bytes |
コンパイル時間 | 17,758 ms |
コンパイル使用メモリ | 167,780 KB |
実行使用メモリ | 217,640 KB |
最終ジャッジ日時 | 2024-12-21 00:12:20 |
合計ジャッジ時間 | 26,309 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 24 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (128 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/
ソースコード
namespace AtCoder;#nullable enableusing System.Numerics;static class Extensions{public static T[] Repeat<T>(this int time, Func<T> F) => Enumerable.Range(0, time).Select(_ => F()).ToArray();}class AtCoder{object? Solve(){var t = Int();var ans = new int[t][];for (var lp = 0; lp < t; lp++){var n = Int();var m = Int();var lns = new int[n];lns[--m] = 1;var q = new PriorityQueue<(int, int, int), (int, int)>();q.Enqueue((0, m, 0), (-m, 0));q.Enqueue((m, n - 1, n - 1), (-(n - 1 - m), n - 1));for (var i = 1; i < n; i++){var (l, r, c) = q.Dequeue();lns[c] = i + 1;var cl = (l + c) / 2;if (cl != l && cl != c) q.Enqueue((l, c, cl), (-Math.Min(c - cl, cl - l), cl));var cr = (c + r) / 2;if (cr != c && cr != r) q.Enqueue((c, r, cr), (-Math.Min(r - cr, cr - c), cr));}ans[lp] = lns;}foreach (var lns in ans) Out(lns, " ");return null;}public static void Main() => new AtCoder().Run();public void Run(){var res = Solve();if (res != null){if (res is bool yes) res = yes ? "Yes" : "No";sw.WriteLine(res);}sw.Flush();}string[] input = Array.Empty<string>();int iter = 0;readonly StreamWriter sw = new(Console.OpenStandardOutput()) { AutoFlush = false };string String(){while (iter >= input.Length) (input, iter) = (Console.ReadLine()!.Split(' '), 0);return input[iter++];}T Input<T>() where T : IParsable<T> => T.Parse(String(), null);int Int() => Input<int>();void Out(object? x, string? separator = null){separator ??= Environment.NewLine;if (x is System.Collections.IEnumerable obj and not string){var firstLine = true;foreach (var item in obj){if (!firstLine) sw.Write(separator);firstLine = false;sw.Write(item);}}else sw.Write(x);sw.WriteLine();}}