結果

問題 No.1894 Delete AB
ユーザー 👑 箱星箱星
提出日時 2022-04-08 21:41:53
言語 Kotlin
(1.9.23)
結果
TLE  
実行時間 -
コード長 1,102 bytes
コンパイル時間 12,510 ms
コンパイル使用メモリ 443,352 KB
実行使用メモリ 120,372 KB
最終ジャッジ日時 2024-05-06 07:14:58
合計ジャッジ時間 22,898 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 276 ms
54,808 KB
testcase_01 AC 572 ms
120,372 KB
testcase_02 AC 571 ms
89,612 KB
testcase_03 AC 467 ms
68,180 KB
testcase_04 AC 466 ms
71,300 KB
testcase_05 AC 493 ms
74,128 KB
testcase_06 AC 484 ms
73,336 KB
testcase_07 AC 503 ms
75,576 KB
testcase_08 AC 517 ms
82,060 KB
testcase_09 AC 488 ms
81,376 KB
testcase_10 AC 491 ms
82,264 KB
testcase_11 AC 498 ms
83,200 KB
testcase_12 AC 528 ms
83,896 KB
testcase_13 TLE -
testcase_14 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:8:13: warning: variable 'n' is never used
        val n = nextInt()
            ^

ソースコード

diff #

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

fun PrintWriter.solve() {
    val numCases = nextInt()
    case@ for (_i in 0 until numCases) {
        val n = nextInt()
        val s = nextLine()
        var t = ""
        for (c in s) {
            t += c
            while (t.endsWith("ABB")) {
                t = t.dropLast(3)
                t += 'B'
            }
        }
        println(t)
    }
}

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