結果

問題 No.2868 Another String of yuusaan
ユーザー 👑 kakel-sankakel-san
提出日時 2024-08-30 23:15:08
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 2,752 bytes
コンパイル時間 8,050 ms
コンパイル使用メモリ 167,908 KB
実行使用メモリ 187,176 KB
最終ジャッジ日時 2024-08-30 23:15:19
合計ジャッジ時間 9,890 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
29,952 KB
testcase_01 AC 53 ms
30,080 KB
testcase_02 AC 53 ms
30,336 KB
testcase_03 AC 54 ms
30,208 KB
testcase_04 AC 55 ms
30,080 KB
testcase_05 AC 54 ms
30,208 KB
testcase_06 AC 57 ms
29,952 KB
testcase_07 AC 54 ms
30,336 KB
testcase_08 AC 53 ms
30,196 KB
testcase_09 WA -
testcase_10 AC 55 ms
30,336 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 55 ms
30,208 KB
testcase_18 AC 55 ms
30,208 KB
testcase_19 AC 54 ms
187,176 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (96 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 long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    public static void Main()
    {
        Solve();
        // Test();
    }
    static void Test()
    {
        var r = new Random();
        var count = 0;
        while (true)
        {
            var n = r.Next(8) + 1;
            var k = r.NextInt64(llist[n]) + 1;
            // 愚直解
            var s1 = All(n, k);
            // 作成解
            var s2 = Yuusaan(n, k);
            if (s1 != s2)
            {
                WriteLine(n + " " + k);
                // WriteLine(string.Join("\n", map.Select(m => string.Join(" ", m))));
                // WriteLine(string.Join(" ", a));
                WriteLine(s1);
                WriteLine(s2);
                return;
            }
            ++count;
            if (count % 1000 == 0) WriteLine(count);
        }
    }
    static char All(int n, long k)
    {
        var s = new List<char>("yuusaan");
        while (n > 1)
        {
            var ns = new List<char>();
            foreach (var si in s)
            {
                if (si == 'u' || si == 'a') ns.AddRange("yuusaan");
                else ns.Add(si);
            }
            --n;
            s = ns;
        }
        return s[(int)k - 1];
    }
    static void Solve()
    {
        var c = NList;
        var (l, k) = (c[0], c[1]);
        WriteLine(Yuusaan(l, k));
    }
    static long[] llist = new long[] { 0, 7, 31, 127, 511, 2047, 8191, 32767, 131071, 524287, 2097151, 8388607,
        33554431, 134217727, 536870911, 2147483647, 8589934591, 34359738367, 137438953471, 549755813887, 2199023255551 };
    static char Yuusaan(long l, long k)
    {
        --k;
        if (l > 20)
        {
            k -= l - 20;
            l = 20;
        }
        if (k < 0)
        {
            return 'y';
        }
        return DFS(k, (int)l);
    }
    static char DFS(long k, int l)
    {
        if (l == 1)
        {
            return "yuusaan"[(int)k];
        }
        var o = 0L;
        if (k == 0)
        {
            return 'y';
        }
        ++o;
        if (k - o < llist[l - 1]) return DFS(k - o, l - 1);
        o += llist[l - 1];
        if (k - o < llist[l - 1]) return DFS(k - o, l - 1);
        o += llist[l - 1];
        if (k - o == 0) return 's';
        ++o;
        if (k - o < llist[l - 1]) return DFS(k - o, l - 1);
        o += llist[l - 1];
        if (k - o < llist[l - 1]) return DFS(k - o, l - 1);
        return 'n';
    }
}
0