結果

問題 No.2209 Flip and Reverse
ユーザー 👑 箱
提出日時 2023-02-10 21:26:29
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 486 ms / 2,000 ms
コード長 1,078 bytes
コンパイル時間 15,168 ms
コンパイル使用メモリ 423,400 KB
実行使用メモリ 60,108 KB
最終ジャッジ日時 2023-09-21 22:28:43
合計ジャッジ時間 31,750 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 281 ms
53,136 KB
testcase_01 AC 285 ms
54,988 KB
testcase_02 AC 281 ms
53,044 KB
testcase_03 AC 287 ms
55,008 KB
testcase_04 AC 288 ms
54,972 KB
testcase_05 AC 287 ms
53,116 KB
testcase_06 AC 283 ms
54,984 KB
testcase_07 AC 284 ms
53,520 KB
testcase_08 AC 475 ms
57,608 KB
testcase_09 AC 286 ms
55,152 KB
testcase_10 AC 288 ms
55,072 KB
testcase_11 AC 288 ms
53,180 KB
testcase_12 AC 288 ms
53,064 KB
testcase_13 AC 284 ms
55,252 KB
testcase_14 AC 464 ms
59,972 KB
testcase_15 AC 465 ms
59,652 KB
testcase_16 AC 466 ms
57,948 KB
testcase_17 AC 467 ms
58,576 KB
testcase_18 AC 469 ms
59,636 KB
testcase_19 AC 469 ms
59,744 KB
testcase_20 AC 462 ms
57,868 KB
testcase_21 AC 463 ms
60,036 KB
testcase_22 AC 464 ms
59,636 KB
testcase_23 AC 463 ms
59,980 KB
testcase_24 AC 467 ms
59,764 KB
testcase_25 AC 473 ms
60,108 KB
testcase_26 AC 470 ms
59,572 KB
testcase_27 AC 486 ms
59,652 KB
testcase_28 AC 472 ms
57,852 KB
testcase_29 AC 473 ms
59,696 KB
testcase_30 AC 463 ms
59,684 KB
testcase_31 AC 465 ms
59,692 KB
testcase_32 AC 454 ms
58,684 KB
testcase_33 AC 452 ms
59,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fun PrintWriter.solve() {
    val n = nextInt()
    val s = nextLine()
    val t = nextLine()
    val c1 = (0 until n).count { s[it] != t[it] }
    val u = s.reversed()
    val c2 = (0 until n).count { u[it] != t[it] }
    val d1 = if (c1 % 2 == 0) c1 else n + 1
    val d2 = if (c2 % 2 == 1) c2 else n + 1
    println(minOf(d1, d2))
}

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