結果

問題 No.2037 NAND Pyramid
ユーザー tomeruntomerun
提出日時 2022-08-12 22:08:17
言語 Crystal
(1.11.2)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 309 bytes
コンパイル時間 12,673 ms
コンパイル使用メモリ 292,812 KB
実行使用メモリ 12,204 KB
最終ジャッジ日時 2023-10-24 10:14:05
合計ジャッジ時間 14,895 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,324 KB
testcase_01 AC 1 ms
4,328 KB
testcase_02 AC 2 ms
4,328 KB
testcase_03 AC 2 ms
4,328 KB
testcase_04 AC 2 ms
4,328 KB
testcase_05 AC 2 ms
4,328 KB
testcase_06 AC 1 ms
4,328 KB
testcase_07 AC 11 ms
6,844 KB
testcase_08 AC 10 ms
7,632 KB
testcase_09 AC 10 ms
6,180 KB
testcase_10 AC 7 ms
5,084 KB
testcase_11 AC 12 ms
6,668 KB
testcase_12 AC 7 ms
4,868 KB
testcase_13 AC 5 ms
4,328 KB
testcase_14 AC 9 ms
5,984 KB
testcase_15 AC 11 ms
6,976 KB
testcase_16 AC 9 ms
5,876 KB
testcase_17 AC 12 ms
7,012 KB
testcase_18 AC 12 ms
7,012 KB
testcase_19 AC 16 ms
7,956 KB
testcase_20 AC 15 ms
7,956 KB
testcase_21 AC 24 ms
12,204 KB
testcase_22 AC 24 ms
12,204 KB
testcase_23 AC 18 ms
10,160 KB
testcase_24 AC 19 ms
10,160 KB
testcase_25 AC 12 ms
7,012 KB
testcase_26 AC 12 ms
7,004 KB
testcase_27 AC 15 ms
7,944 KB
testcase_28 AC 12 ms
7,012 KB
testcase_29 AC 12 ms
7,004 KB
testcase_30 AC 18 ms
10,188 KB
testcase_31 AC 18 ms
9,716 KB
testcase_32 AC 15 ms
7,956 KB
testcase_33 AC 2 ms
4,328 KB
testcase_34 AC 2 ms
4,328 KB
testcase_35 AC 2 ms
4,328 KB
testcase_36 AC 2 ms
4,328 KB
testcase_37 AC 2 ms
4,328 KB
testcase_38 AC 2 ms
4,328 KB
testcase_39 AC 2 ms
4,328 KB
testcase_40 AC 1 ms
4,328 KB
testcase_41 AC 2 ms
4,328 KB
testcase_42 AC 2 ms
4,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = read_line.split.map(&.to_i)
k = n - k
s = read_line.chars.map(&.to_i)
1.upto(n - 2) do |i|
  if s[i - 1] == 0 && s[i] == 1 && s[i + 1] == 0
    s[i] = 0
  end
end
s = s[k // 2, n - (k // 2) * 2]
if k % 2 != 0
  s = (s.size - 1).times.map { |i| s[i] == 1 && s[i + 1] == 1 ? 0 : 1 }.to_a
end
puts s.join
0