結果

問題 No.2845 Birthday Pattern in Two Different Calendars
ユーザー 👑 kakel-sankakel-san
提出日時 2024-08-23 22:03:07
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 367 ms / 2,000 ms
コード長 1,365 bytes
コンパイル時間 11,103 ms
コンパイル使用メモリ 166,232 KB
実行使用メモリ 219,880 KB
最終ジャッジ日時 2024-08-23 22:03:23
合計ジャッジ時間 11,760 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
30,976 KB
testcase_01 AC 81 ms
36,480 KB
testcase_02 AC 84 ms
40,440 KB
testcase_03 AC 63 ms
31,076 KB
testcase_04 AC 81 ms
37,248 KB
testcase_05 AC 76 ms
36,216 KB
testcase_06 AC 70 ms
34,072 KB
testcase_07 AC 73 ms
34,560 KB
testcase_08 AC 68 ms
32,512 KB
testcase_09 AC 65 ms
31,744 KB
testcase_10 AC 64 ms
30,580 KB
testcase_11 AC 68 ms
32,384 KB
testcase_12 AC 83 ms
39,936 KB
testcase_13 AC 68 ms
32,128 KB
testcase_14 AC 64 ms
30,720 KB
testcase_15 AC 66 ms
31,996 KB
testcase_16 AC 69 ms
31,852 KB
testcase_17 AC 69 ms
32,512 KB
testcase_18 AC 71 ms
34,656 KB
testcase_19 AC 83 ms
39,408 KB
testcase_20 AC 72 ms
33,408 KB
testcase_21 AC 88 ms
40,312 KB
testcase_22 AC 367 ms
219,880 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (98 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/

ソースコード

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();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var t = NN;
        var ans = new string[t];
        for (var u = 0; u < t; ++u)
        {
            var c = NList;
            ans[u] = Cal(c[0], c[1], c[2]);
        }
        WriteLine(string.Join("\n", ans));
    }
    static string Cal(int k, int m, int n)
    {
        if (n * 2 > k) return "No";
        if (m == 1) return "No";
        var visited = new bool[k];
        var ans = new List<int>();
        for (var i = 0; i < k; ++i)
        {
            var y = i;
            var c = (y + m - 1) % k;
            while (!visited[y] && !visited[c])
            {
                ans.Add(y);
                visited[y] = true;
                visited[c] = true;
                y = (c + m - 1) % k;
                c = (y + m - 1) % k;
            }
        }
        if (ans.Count < n) return "No";
        return $"Yes\n{string.Join(" ", ans.Take(n).Select(ai => ai + 1))}";
    }
}
0