結果
問題 | No.1707 Simple Range Reverse Problem |
ユーザー |
|
提出日時 | 2021-08-08 00:41:52 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 386 ms / 2,000 ms |
コード長 | 1,305 bytes |
コンパイル時間 | 13,322 ms |
コンパイル使用メモリ | 440,984 KB |
実行使用メモリ | 58,884 KB |
最終ジャッジ日時 | 2024-09-17 17:00:39 |
合計ジャッジ時間 | 20,763 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 18 |
ソースコード
import java.io.PrintWriterimport 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 Scannerprivate 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