結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 89 ms
12,288 KB
testcase_03 AC 90 ms
12,032 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 = ''
w.times {|i|
  h.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