結果

問題 No.1707 Simple Range Reverse Problem
ユーザー magurofly
提出日時 2021-10-15 21:31:07
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 365 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-09-17 17:15:23
合計ジャッジ時間 2,875 ms
ジャッジサーバーID
(参考情報)
judge1 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12 WA * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

T = gets.to_s.to_i
T.times do
    n = gets.to_s.to_i
    a = gets.to_s.split.map { |s| s.to_i }
    
    if (0 ... n * 2).all? { |i| a[i] == i % n + 1 }
        puts "Yes"
        next
    end
    
    i = a.rindex(1)
    xs = a[0 .. i]
    ys = a[i + 1 ..]
    if xs.reverse == xs and ys.reverse == ys
        puts "Yes"
        next
    end
    
    puts "No"
end
0