結果

問題 No.1707 Simple Range Reverse Problem
ユーザー 👑 箱
提出日時 2021-08-08 00:41:52
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 411 ms / 2,000 ms
コード長 1,305 bytes
コンパイル時間 16,973 ms
コンパイル使用メモリ 438,768 KB
実行使用メモリ 60,652 KB
最終ジャッジ日時 2023-10-17 19:48:30
合計ジャッジ時間 25,991 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 285 ms
51,672 KB
testcase_01 AC 301 ms
51,760 KB
testcase_02 AC 301 ms
51,772 KB
testcase_03 AC 309 ms
51,784 KB
testcase_04 AC 411 ms
60,404 KB
testcase_05 AC 383 ms
60,652 KB
testcase_06 AC 302 ms
51,760 KB
testcase_07 AC 304 ms
51,764 KB
testcase_08 AC 306 ms
51,772 KB
testcase_09 AC 361 ms
56,880 KB
testcase_10 AC 361 ms
56,856 KB
testcase_11 AC 333 ms
54,604 KB
testcase_12 AC 362 ms
57,564 KB
testcase_13 AC 373 ms
57,588 KB
testcase_14 AC 343 ms
57,340 KB
testcase_15 AC 370 ms
57,596 KB
testcase_16 AC 359 ms
57,584 KB
testcase_17 AC 329 ms
57,340 KB
testcase_18 AC 360 ms
57,592 KB
権限があれば一括ダウンロードができます

ソースコード

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 a = Array(2 * n) { nextInt() }
        val x = Array(2 * n) { if (it < n) it + 1 else it - n + 1 }
        if (a.contentEquals(x)) {
            println("Yes")
            continue@case
        }
        for (i in 0 until n) {
            val b = Array(2 * n) { 0 }
            for (j in 0 until 2 * n) {
                if (j <= i || j >= i + n) {
                    b[j] = x[j]
                } else {
                    b[j] = x[2 * i + n - j]
                }
            }
            if (a.contentEquals(b)) {
                println("Yes")
                continue@case
            }
        }
        println("No")
    }
}

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