結果

問題 No.82 市松模様
ユーザー d_nishiyama85d_nishiyama85
提出日時 2016-06-05 15:36:44
言語 Ruby
(3.3.0)
結果
AC  
実行時間 91 ms / 5,000 ms
コード長 390 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 14,208 KB
最終ジャッジ日時 2024-04-17 04:51:24
合計ジャッジ時間 1,708 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
12,416 KB
testcase_01 AC 87 ms
12,288 KB
testcase_02 AC 86 ms
12,160 KB
testcase_03 AC 87 ms
12,416 KB
testcase_04 AC 91 ms
12,288 KB
testcase_05 AC 88 ms
12,160 KB
testcase_06 AC 86 ms
12,288 KB
testcase_07 AC 87 ms
12,288 KB
testcase_08 AC 90 ms
13,952 KB
testcase_09 AC 91 ms
14,208 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:11: warning: mismatched indentations at 'else' with 'if' at 8
Main.rb:13: warning: mismatched indentations at 'end' with 'else' at 11
Syntax OK

ソースコード

diff #

w, h, c = gets.strip.split(' ')
w = w.to_i
h = h.to_i
result = ''
h.times {|i|
  w.times {|j|
    result +=
    if i % 2 == 0
      then
        if j % 2 == 0 then '0' else '1' end
      else
        if j % 2 == 1 then '0' else '1' end
    end
  }
  result += "\n"
}

if c === 'W' then
  result.gsub!('0', 'W').gsub!('1', 'B')
else
  result.gsub!('0', 'B').gsub!('1', 'W')
end

puts result
0