結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー 👑 箱星箱星
提出日時 2020-12-09 17:01:45
言語 Kotlin
(1.9.23)
結果
TLE  
実行時間 -
コード長 1,085 bytes
コンパイル時間 10,769 ms
コンパイル使用メモリ 439,124 KB
実行使用メモリ 62,504 KB
最終ジャッジ日時 2023-10-21 12:40:31
合計ジャッジ時間 24,127 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 256 ms
52,052 KB
testcase_01 AC 253 ms
52,056 KB
testcase_02 AC 258 ms
52,056 KB
testcase_03 AC 259 ms
52,040 KB
testcase_04 AC 248 ms
52,056 KB
testcase_05 AC 246 ms
52,056 KB
testcase_06 AC 252 ms
52,056 KB
testcase_07 AC 255 ms
52,056 KB
testcase_08 AC 256 ms
52,060 KB
testcase_09 AC 257 ms
52,056 KB
testcase_10 AC 254 ms
52,060 KB
testcase_11 AC 252 ms
52,048 KB
testcase_12 AC 256 ms
52,060 KB
testcase_13 AC 254 ms
52,064 KB
testcase_14 AC 263 ms
52,060 KB
testcase_15 AC 255 ms
52,060 KB
testcase_16 AC 249 ms
52,056 KB
testcase_17 AC 246 ms
52,044 KB
testcase_18 AC 250 ms
52,048 KB
testcase_19 AC 252 ms
52,056 KB
testcase_20 AC 256 ms
52,056 KB
testcase_21 AC 247 ms
52,044 KB
testcase_22 AC 424 ms
60,220 KB
testcase_23 AC 364 ms
57,812 KB
testcase_24 AC 366 ms
57,812 KB
testcase_25 AC 439 ms
60,064 KB
testcase_26 AC 465 ms
62,504 KB
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fun PrintWriter.solve() {
    val n = nextInt()
    val a = Array(n) { nextInt() }
    if (isSorted(a)) {
        println(0)
        return
    }
    for (i in 1..n) {
        for (j in 1 until i) {
            val b = a.copyOf()
            for (k in 0 until i) {
                b[k] = a[(j + k) % i]
            }
            if (isSorted(b)) {
                println(1)
                return
            }
        }
    }
    println(2)
}

fun isSorted(a: Array<Int>): Boolean {
    return (0 until a.count() - 1).all { a[it] <= a[it + 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