結果

問題 No.1894 Delete AB
ユーザー 箱星
提出日時 2022-04-08 21:41:53
言語 Kotlin
(2.1.0)
結果
TLE  
実行時間 -
コード長 1,102 bytes
コンパイル時間 15,028 ms
コンパイル使用メモリ 441,328 KB
実行使用メモリ 165,368 KB
最終ジャッジ日時 2024-11-28 12:19:56
合計ジャッジ時間 28,962 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12 TLE * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
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