結果

問題 No.1362 [Zelkova 8th Tune] Black Sheep
ユーザー qszhuqszhu
提出日時 2022-10-07 16:54:48
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 380 ms / 1,000 ms
コード長 728 bytes
コンパイル時間 17,162 ms
コンパイル使用メモリ 418,200 KB
実行使用メモリ 57,736 KB
最終ジャッジ日時 2023-09-02 17:23:48
合計ジャッジ時間 29,558 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 281 ms
54,908 KB
testcase_01 AC 281 ms
52,760 KB
testcase_02 AC 281 ms
52,856 KB
testcase_03 AC 286 ms
54,748 KB
testcase_04 AC 286 ms
52,916 KB
testcase_05 AC 283 ms
54,700 KB
testcase_06 AC 282 ms
53,272 KB
testcase_07 AC 285 ms
55,040 KB
testcase_08 AC 282 ms
54,724 KB
testcase_09 AC 283 ms
54,700 KB
testcase_10 AC 283 ms
53,504 KB
testcase_11 AC 286 ms
54,652 KB
testcase_12 AC 284 ms
54,968 KB
testcase_13 AC 356 ms
57,584 KB
testcase_14 AC 341 ms
55,508 KB
testcase_15 AC 297 ms
54,852 KB
testcase_16 AC 343 ms
55,288 KB
testcase_17 AC 356 ms
56,248 KB
testcase_18 AC 351 ms
55,868 KB
testcase_19 AC 355 ms
55,792 KB
testcase_20 AC 356 ms
57,492 KB
testcase_21 AC 349 ms
55,664 KB
testcase_22 AC 342 ms
55,724 KB
testcase_23 AC 357 ms
57,736 KB
testcase_24 AC 359 ms
57,728 KB
testcase_25 AC 360 ms
55,724 KB
testcase_26 AC 380 ms
57,712 KB
testcase_27 AC 346 ms
57,584 KB
testcase_28 AC 363 ms
57,652 KB
testcase_29 AC 359 ms
55,848 KB
testcase_30 AC 361 ms
57,404 KB
testcase_31 AC 359 ms
55,712 KB
testcase_32 AC 357 ms
57,564 KB
testcase_33 AC 360 ms
55,644 KB
testcase_34 AC 345 ms
57,692 KB
testcase_35 AC 281 ms
54,808 KB
testcase_36 AC 283 ms
56,648 KB
testcase_37 AC 288 ms
53,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import kotlin.system.exitProcess

val br = System.`in`.bufferedReader()

fun readLine(): String? = br.readLine()
fun readString() = readLine()!!

const val MAX_STACK_SIZE: Long = 128 * 1024 * 1024

fun main() {
    val thread = Thread(null, ::run, "solve", MAX_STACK_SIZE)
    thread.setUncaughtExceptionHandler { _, e -> e.printStackTrace(); exitProcess(1) }
    thread.start()
}

fun run() {
    val S = readString()
    output(solve(S))
}

fun solve(S: String): Pair<Int, Char> {
    if (S[0] == S[1]) {
        for (i in 2..S.lastIndex) if (S[i] != S[0]) return i + 1 to S[i]
    }
    if (S[0] == S.last()) return 2 to S[1]
    return 1 to S[0]
}

fun output(res: Pair<Int, Char>) = res.apply { println("$first $second") }
0