結果

問題 No.1707 Simple Range Reverse Problem
ユーザー maguroflymagurofly
提出日時 2021-10-15 21:31:07
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 365 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 11,876 KB
実行使用メモリ 16,188 KB
最終ジャッジ日時 2023-10-17 20:03:37
合計ジャッジ時間 2,640 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
16,048 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 87 ms
16,048 KB
testcase_05 AC 86 ms
16,048 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 86 ms
16,048 KB
testcase_10 AC 86 ms
16,044 KB
testcase_11 AC 86 ms
16,048 KB
testcase_12 AC 88 ms
16,048 KB
testcase_13 AC 89 ms
16,048 KB
testcase_14 AC 90 ms
16,048 KB
testcase_15 AC 90 ms
16,048 KB
testcase_16 AC 90 ms
16,048 KB
testcase_17 AC 88 ms
16,048 KB
testcase_18 AC 88 ms
16,048 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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