結果
| 問題 |
No.1707 Simple Range Reverse Problem
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2022-01-02 23:49:25 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 732 bytes |
| コンパイル時間 | 388 ms |
| コンパイル使用メモリ | 7,972 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-07-13 03:52:57 |
| 合計ジャッジ時間 | 1,038 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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