結果

問題 No.1764 Square
ユーザー 👑 箱
提出日時 2021-11-26 23:49:03
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 285 ms / 2,000 ms
コード長 1,151 bytes
コンパイル時間 13,546 ms
コンパイル使用メモリ 422,120 KB
実行使用メモリ 55,224 KB
最終ジャッジ日時 2023-09-12 05:41:21
合計ジャッジ時間 16,053 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 280 ms
53,100 KB
testcase_01 AC 280 ms
53,280 KB
testcase_02 AC 276 ms
55,024 KB
testcase_03 AC 284 ms
53,152 KB
testcase_04 AC 281 ms
53,516 KB
testcase_05 AC 285 ms
55,224 KB
testcase_06 AC 279 ms
55,132 KB
testcase_07 AC 279 ms
55,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter
import java.util.*
import kotlin.math.*

fun PrintWriter.solve() {
    val k = nextInt()
    val ques = Array(4) { ArrayDeque<Char>() }
    ques[0].addLast('A')
    ques[0].addLast('E')
    ques[1].addLast('B')
    ques[2].addLast('C')
    ques[3].addLast('D')
    for (i in 0 until k) {
        val c = ques[i % 4].pollFirst()!!
        ques[(i + 1) % 4].addLast(c)
    }
    for (i in 0 until 4) {
        println(ques[i].joinToString(""))
    }
}

fun main() {
    Thread(null, {
        val writer = PrintWriter(System.out, false)
        writer.solve()
        writer.flush()
    }, "solve", abs(1L.shl(26)))
        .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }
        .apply { start() }.join()
}

// region Scanner
private var st = StringTokenizer("")
private val br = System.`in`.bufferedReader()

fun next(): String {
    while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())
    return st.nextToken()
}

fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextLine() = br.readLine()
fun nextDouble() = next().toDouble()
// endregion
0