結果

問題 No.1617 Palindrome Removal
ユーザー 👑 箱星箱星
提出日時 2021-07-22 21:29:41
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 837 bytes
コンパイル時間 15,588 ms
コンパイル使用メモリ 412,660 KB
実行使用メモリ 57,960 KB
最終ジャッジ日時 2023-09-24 15:47:09
合計ジャッジ時間 27,378 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 462 ms
57,956 KB
testcase_01 AC 467 ms
57,912 KB
testcase_02 AC 478 ms
57,852 KB
testcase_03 AC 481 ms
57,960 KB
testcase_04 AC 475 ms
57,924 KB
testcase_05 AC 467 ms
57,880 KB
testcase_06 AC 371 ms
56,240 KB
testcase_07 AC 376 ms
56,232 KB
testcase_08 AC 284 ms
52,924 KB
testcase_09 AC 282 ms
52,716 KB
testcase_10 AC 464 ms
57,800 KB
testcase_11 AC 468 ms
57,732 KB
testcase_12 AC 473 ms
57,768 KB
testcase_13 AC 465 ms
57,924 KB
testcase_14 AC 326 ms
57,080 KB
testcase_15 AC 281 ms
52,748 KB
testcase_16 AC 317 ms
57,308 KB
testcase_17 AC 322 ms
57,072 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 324 ms
56,976 KB
testcase_21 AC 331 ms
56,828 KB
testcase_22 AC 326 ms
57,120 KB
testcase_23 AC 322 ms
56,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fun PrintWriter.solve() {
    val s = nextLine()
    val t = s.reversed()
    if (s != t) {
        println(s.length)
    } else if (s.toCharArray().distinct().count() > 1) {
        println(s.length - 2)
    } else if (s.length % 2 == 0) {
        println(0)
    } else {
        println(-1)
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve()
    writer.flush()
}

// 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