結果
| 問題 | No.1707 Simple Range Reverse Problem |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-02 23:49:25 |
| 言語 | Lua (LuaJit 2.1.1774638290) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| + 367µs | |
| コード長 | 732 bytes |
| 記録 | |
| コンパイル時間 | 150 ms |
| コンパイル使用メモリ | 7,208 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-13 05:28:28 |
| 合計ジャッジ時間 | 1,442 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 19 |
ソースコード
local q = io.read("*n")
local a = {}
local c = {}
local function solve()
local n = io.read("*n")
for i = 1, 2 * n do
a[i] = io.read("*n")
end
if a[1] ~= 1 then return false end
local spos = 0
for i = 2, n + 1 do
if i <= n and a[i] ~= i then
spos = i - 1 break
elseif i == n + 1 and a[i] ~= 1 then
spos = i - 1 break
end
end
if 0 < spos then
local tpos = spos + n
for i = spos + 1, tpos - 1 do
local j = spos + tpos - i
if j <= i then break end
a[i], a[j] = a[j], a[i]
end
end
for i = 1, n do
if a[i] ~= i then return false end
if a[n + i] ~= i then return false end
end
return true
end
for iq = 1, q do
print(solve() and "Yes" or "No")
end