結果

問題 No.2652 [Cherry 6th Tune N] Δρονε χιρχλινγ
ユーザー tobisatistobisatis
提出日時 2024-02-23 23:04:30
言語 C#
(.NET 8.0.203)
結果
RE  
実行時間 -
コード長 2,860 bytes
コンパイル時間 7,367 ms
コンパイル使用メモリ 157,812 KB
実行使用メモリ 207,980 KB
最終ジャッジ日時 2024-02-23 23:06:09
合計ジャッジ時間 67,878 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
32,164 KB
testcase_01 AC 558 ms
57,636 KB
testcase_02 AC 570 ms
57,764 KB
testcase_03 AC 606 ms
57,636 KB
testcase_04 AC 763 ms
69,160 KB
testcase_05 AC 725 ms
68,392 KB
testcase_06 AC 756 ms
65,200 KB
testcase_07 AC 744 ms
75,348 KB
testcase_08 AC 745 ms
78,616 KB
testcase_09 AC 755 ms
72,740 KB
testcase_10 AC 791 ms
66,720 KB
testcase_11 AC 729 ms
72,556 KB
testcase_12 AC 738 ms
68,020 KB
testcase_13 AC 841 ms
75,900 KB
testcase_14 RE -
testcase_15 AC 781 ms
81,188 KB
testcase_16 AC 750 ms
77,868 KB
testcase_17 AC 802 ms
79,244 KB
testcase_18 AC 758 ms
76,100 KB
testcase_19 AC 786 ms
75,520 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 AC 460 ms
61,348 KB
testcase_41 AC 456 ms
207,980 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (97 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 #

namespace AtCoder;

#nullable enable

using 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 List<List<(int, int)>>();
        for (var i = 0; i < t; i++)
        {
            ans.Add(Solve2());
        }
        foreach (var l in ans)
        {
            Out(l.Count);
            foreach (var (x, y) in l) Out(x + " " + y);
        }
        return null;
    }

    List<(int, int)> Solve2()
    {
        var res = new List<(int, int)>();
        var n = Int();
        var l = Int();
        var d = 1;
        while (d * d <= n) d++;
        var z = l / d + 1;
        var g = new Dictionary<(int, int), List<(int, int)>>();
        for (var i = 0; i < n; i++)
        {
            var x = Int();
            var y = Int();
            var (xd, yd) = (x / z, y / z);
            if (!g.ContainsKey((xd, yd))) g[(xd, yd)] = new();
            g[(xd, yd)].Add((x, y));
        }
        var az = new List<(int, int)>(g.Keys);
        az.Sort();
        foreach (var k in az)
        {
            var a = g[k];
            a.Sort();
            foreach (var (x, y) in a) res.Add((x, y));
        }

        {
            var check = 0L;
            var (xl, yl) = res[^1];
            foreach (var (x, y) in res)
            {
                check += Math.Abs(x - xl) + Math.Abs(y - yl);
                (xl, yl) = (x, y);
            }
            if (check >= 1000L * l) throw new Exception();
        }
        
        return res;
    }

    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 };

    #pragma warning disable IDE0051
    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();
    }
    #pragma warning restore IDE0051
}
0