結果
問題 |
No.82 市松模様
|
ユーザー |
|
提出日時 | 2018-03-25 16:38:30 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 325 ms / 5,000 ms |
コード長 | 859 bytes |
コンパイル時間 | 13,130 ms |
コンパイル使用メモリ | 434,832 KB |
実行使用メモリ | 67,036 KB |
最終ジャッジ日時 | 2024-11-20 14:49:36 |
合計ジャッジ時間 | 15,616 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 |
コンパイルメッセージ
Main.kt:6:10: warning: parameter 'args' is never used fun main(args: Array<String>) { ^
ソースコード
package yukicoder.no82 /** * エントリポイント */ fun main(args: Array<String>) { val in1 = readLine() print(checkeredPattern(in1)) } /** * 幅、高さ、色をもとに市松模様を返します。最後に改行が入ります。 * @param widthHeightColor 幅、高さ、色 */ fun checkeredPattern(widthHeightColor: String?): String { if (widthHeightColor == null) { return "" } var pattern = "" val sp = widthHeightColor.split(" ") // true="B",false="W" var color = sp[2] == "B" for (h in 1..sp[1].toInt()) { for (w in 1..sp[0].toInt()) { pattern += if (color) "B" else "W" color = !color } // 偶数の場合は反転 if (sp[0].toInt() % 2 == 0) { color = !color } pattern += "\n" } return pattern }