結果

問題 No.2652 [Cherry 6th Tune N] Δρονε χιρχλινγ
ユーザー tobisatistobisatis
提出日時 2024-02-23 23:16:31
言語 C#
(.NET 8.0.203)
結果
RE  
実行時間 -
コード長 3,288 bytes
コンパイル時間 10,278 ms
コンパイル使用メモリ 158,644 KB
実行使用メモリ 213,872 KB
最終ジャッジ日時 2024-02-23 23:17:58
合計ジャッジ時間 80,493 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
32,292 KB
testcase_01 AC 687 ms
58,532 KB
testcase_02 AC 665 ms
58,404 KB
testcase_03 AC 690 ms
58,020 KB
testcase_04 AC 813 ms
65,088 KB
testcase_05 AC 843 ms
65,604 KB
testcase_06 AC 836 ms
65,652 KB
testcase_07 AC 917 ms
69,560 KB
testcase_08 AC 935 ms
76,144 KB
testcase_09 AC 945 ms
78,120 KB
testcase_10 AC 920 ms
65,340 KB
testcase_11 AC 927 ms
75,764 KB
testcase_12 AC 941 ms
82,592 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 960 ms
72,632 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
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 499 ms
62,116 KB
testcase_41 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (101 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 * 2) 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 kz = new List<(int, int)>(g.Keys);
        kz.Sort();
        var kz2 = new Dictionary<int, List<int>>();
        foreach (var (x, y) in kz)
        {
            if (!kz2.ContainsKey(x)) kz2[x] = new();
            kz2[x].Add(y);
        }
        var rev = false;
        foreach (var (x, yl) in kz2)
        {
            yl.Sort();
            if (rev)
            {
                yl.Reverse();
                rev = !rev;
            }
            foreach (var y in yl)
            {
                var a = g[(x, y)];
                a.Sort();
                foreach (var (xo, yo) in a) res.Add((xo, yo));
            }
        }

        {
            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