結果
| 問題 |
No.1707 Simple Range Reverse Problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-08 00:41:52 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
AC
|
| 実行時間 | 470 ms / 2,000 ms |
| コード長 | 1,305 bytes |
| コンパイル時間 | 15,637 ms |
| コンパイル使用メモリ | 457,600 KB |
| 実行使用メモリ | 68,324 KB |
| 最終ジャッジ日時 | 2025-07-13 03:50:07 |
| 合計ジャッジ時間 | 24,349 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 19 |
ソースコード
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