結果

問題 No.2037 NAND Pyramid
ユーザー 👑 kakel-sankakel-san
提出日時 2023-10-24 22:03:19
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 1,122 bytes
コンパイル時間 11,467 ms
コンパイル使用メモリ 157,196 KB
実行使用メモリ 176,924 KB
最終ジャッジ日時 2023-10-24 22:03:42
合計ジャッジ時間 18,643 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
32,396 KB
testcase_01 AC 79 ms
32,352 KB
testcase_02 AC 82 ms
32,392 KB
testcase_03 AC 82 ms
32,396 KB
testcase_04 AC 79 ms
32,356 KB
testcase_05 AC 81 ms
32,396 KB
testcase_06 AC 80 ms
32,396 KB
testcase_07 AC 110 ms
39,912 KB
testcase_08 AC 104 ms
40,312 KB
testcase_09 AC 101 ms
37,880 KB
testcase_10 AC 96 ms
37,672 KB
testcase_11 AC 105 ms
38,504 KB
testcase_12 AC 92 ms
35,608 KB
testcase_13 AC 89 ms
35,216 KB
testcase_14 AC 98 ms
37,548 KB
testcase_15 AC 107 ms
40,108 KB
testcase_16 AC 98 ms
37,568 KB
testcase_17 AC 108 ms
41,136 KB
testcase_18 AC 110 ms
41,136 KB
testcase_19 AC 115 ms
41,192 KB
testcase_20 AC 114 ms
41,192 KB
testcase_21 AC 97 ms
39,016 KB
testcase_22 AC 98 ms
39,016 KB
testcase_23 AC 121 ms
41,168 KB
testcase_24 AC 121 ms
41,180 KB
testcase_25 AC 108 ms
41,128 KB
testcase_26 AC 108 ms
41,120 KB
testcase_27 AC 115 ms
41,180 KB
testcase_28 AC 107 ms
41,128 KB
testcase_29 AC 107 ms
41,124 KB
testcase_30 AC 120 ms
41,196 KB
testcase_31 AC 115 ms
41,196 KB
testcase_32 AC 114 ms
41,196 KB
testcase_33 AC 81 ms
32,624 KB
testcase_34 AC 82 ms
32,664 KB
testcase_35 AC 83 ms
32,736 KB
testcase_36 AC 81 ms
32,660 KB
testcase_37 AC 82 ms
32,668 KB
testcase_38 AC 82 ms
32,748 KB
testcase_39 AC 83 ms
32,668 KB
testcase_40 AC 84 ms
32,628 KB
testcase_41 AC 88 ms
32,656 KB
testcase_42 AC 83 ms
176,924 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (105 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 #

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 c = NList;
        var (n, k) = (c[0], c[1]);
        var s = ReadLine();
        if (n - k == 1)
        {
            WriteLine(Up(s));
            return;
        }
        var n1 = Up(s);
        var n2 = Up(n1);
        if ((n - k) % 2 == 0)
        {
            WriteLine(string.Concat(n2.Skip((n - k) / 2 - 1).Take(k)));
        }
        else
        {
            WriteLine(string.Concat(n1.Skip((n - k) / 2).Take(k)));
        }
    }
    static string Up(string s)
    {
        var c = new List<char>();
        for (var i = 0; i + 1 < s.Length; ++i) c.Add(s[i] == '1' && s[i + 1] == '1' ? '0' : '1');
        return string.Concat(c);
    }
}
0