結果

問題 No.2432 Flip and Move
ユーザー tomeruntomerun
提出日時 2023-08-18 23:04:59
言語 Crystal
(1.11.2)
結果
AC  
実行時間 1,724 ms / 2,000 ms
コード長 606 bytes
コンパイル時間 13,031 ms
コンパイル使用メモリ 295,612 KB
実行使用メモリ 91,648 KB
最終ジャッジ日時 2024-05-06 05:37:47
合計ジャッジ時間 24,240 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 43 ms
5,888 KB
testcase_03 AC 1,724 ms
91,648 KB
testcase_04 AC 31 ms
5,376 KB
testcase_05 AC 18 ms
5,376 KB
testcase_06 AC 25 ms
5,376 KB
testcase_07 AC 1,082 ms
60,800 KB
testcase_08 AC 1,161 ms
72,448 KB
testcase_09 AC 1,595 ms
90,496 KB
testcase_10 AC 28 ms
5,504 KB
testcase_11 AC 24 ms
5,504 KB
testcase_12 AC 26 ms
5,376 KB
testcase_13 AC 17 ms
5,376 KB
testcase_14 AC 381 ms
23,424 KB
testcase_15 AC 1,350 ms
76,672 KB
testcase_16 AC 17 ms
5,376 KB
testcase_17 AC 50 ms
5,376 KB
testcase_18 AC 20 ms
5,376 KB
testcase_19 AC 41 ms
5,376 KB
testcase_20 AC 55 ms
5,376 KB
testcase_21 AC 26 ms
5,376 KB
testcase_22 AC 35 ms
5,376 KB
testcase_23 AC 23 ms
5,376 KB
testcase_24 AC 40 ms
5,376 KB
testcase_25 AC 35 ms
5,376 KB
testcase_26 AC 54 ms
5,376 KB
testcase_27 AC 4 ms
5,376 KB
testcase_28 AC 3 ms
5,376 KB
testcase_29 AC 29 ms
5,376 KB
testcase_30 AC 34 ms
5,376 KB
testcase_31 AC 33 ms
5,376 KB
testcase_32 AC 5 ms
5,376 KB
testcase_33 AC 31 ms
5,376 KB
testcase_34 AC 14 ms
5,376 KB
testcase_35 AC 31 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w = read_line.split.map(&.to_i)
k = read_line.to_i64
k %= (h * w * 4)
y = 0
x = 0
dy = 1
dx = 1
ans = Array.new(h) { Array.new(w, false) }
k.times do
  ans[y][x] = !ans[y][x]
  if y + dy < 0 || h <= y + dy
    dy *= -1
  else
    y += dy
  end
  if x + dx < 0 || w <= x + dx
    dx *= -1
  else
    x += dx
  end
end
h.times do |i|
  puts w.times.map { |j| ans[i][j] ? '#' : '.' }.join
end

def move(l, k)
  ret = Array.new(l, false)
  len = k % (l * 2)
  if len < k
    len.times { |i| ret[i] = true }
  else
    ret.fill(true)
    (len - k).times { |i| ret[l - 1 - i] = false }
  end
  return ret
end
0