結果

問題 No.2845 Birthday Pattern in Two Different Calendars
コンテスト
ユーザー kakel-san
提出日時 2024-08-23 22:03:07
言語 C#
(.NET 10.0.201)
コンパイル:
dotnet_c
実行:
/usr/bin/dotnet_wrap
結果
AC  
実行時間 228 ms / 2,000 ms
コード長 1,365 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 13,975 ms
コンパイル使用メモリ 174,288 KB
実行使用メモリ 236,156 KB
最終ジャッジ日時 2026-04-03 21:59:06
合計ジャッジ時間 9,330 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (139 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

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