結果

問題 No.2432 Flip and Move
ユーザー tomeruntomerun
提出日時 2023-08-18 23:04:59
言語 Crystal
(1.11.2)
結果
AC  
実行時間 1,403 ms / 2,000 ms
コード長 606 bytes
コンパイル時間 18,333 ms
コンパイル使用メモリ 254,012 KB
実行使用メモリ 105,556 KB
最終ジャッジ日時 2023-08-18 23:05:50
合計ジャッジ時間 28,222 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,404 KB
testcase_01 AC 3 ms
4,484 KB
testcase_02 AC 31 ms
7,516 KB
testcase_03 AC 1,403 ms
105,556 KB
testcase_04 AC 20 ms
6,196 KB
testcase_05 AC 12 ms
6,120 KB
testcase_06 AC 19 ms
5,768 KB
testcase_07 AC 952 ms
62,588 KB
testcase_08 AC 963 ms
84,936 KB
testcase_09 AC 1,340 ms
103,212 KB
testcase_10 AC 21 ms
7,120 KB
testcase_11 AC 17 ms
7,240 KB
testcase_12 AC 19 ms
7,028 KB
testcase_13 AC 12 ms
6,956 KB
testcase_14 AC 326 ms
26,992 KB
testcase_15 AC 1,205 ms
94,380 KB
testcase_16 AC 11 ms
5,476 KB
testcase_17 AC 33 ms
6,352 KB
testcase_18 AC 15 ms
5,788 KB
testcase_19 AC 30 ms
6,252 KB
testcase_20 AC 39 ms
6,960 KB
testcase_21 AC 18 ms
6,100 KB
testcase_22 AC 20 ms
6,848 KB
testcase_23 AC 31 ms
6,300 KB
testcase_24 AC 25 ms
6,120 KB
testcase_25 AC 26 ms
6,280 KB
testcase_26 AC 39 ms
6,840 KB
testcase_27 AC 3 ms
4,592 KB
testcase_28 AC 3 ms
4,620 KB
testcase_29 AC 17 ms
6,348 KB
testcase_30 AC 26 ms
7,012 KB
testcase_31 AC 22 ms
6,124 KB
testcase_32 AC 5 ms
4,500 KB
testcase_33 AC 20 ms
6,216 KB
testcase_34 AC 10 ms
5,928 KB
testcase_35 AC 21 ms
5,620 KB
testcase_36 AC 2 ms
4,364 KB
testcase_37 AC 2 ms
4,492 KB
testcase_38 AC 2 ms
4,364 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