結果

問題 No.1707 Simple Range Reverse Problem
ユーザー simansiman
提出日時 2021-10-16 10:55:32
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 445 bytes
コンパイル時間 56 ms
コンパイル使用メモリ 11,940 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2023-10-17 22:04:41
合計ジャッジ時間 2,601 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
16,124 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 90 ms
16,124 KB
testcase_05 AC 88 ms
16,124 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 84 ms
16,244 KB
testcase_09 AC 84 ms
16,124 KB
testcase_10 AC 84 ms
16,132 KB
testcase_11 AC 85 ms
16,128 KB
testcase_12 AC 85 ms
16,144 KB
testcase_13 AC 86 ms
16,148 KB
testcase_14 AC 85 ms
16,124 KB
testcase_15 AC 85 ms
16,148 KB
testcase_16 AC 84 ms
16,132 KB
testcase_17 AC 84 ms
16,124 KB
testcase_18 AC 85 ms
16,148 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

T = gets.to_i

T.times do
  n = gets.to_i
  a = gets.split.map(&:to_i)
  x = [*1..n] * 2

  if a[0] != 1 || a[-1] != n || a.sort != x.sort
    puts 'No'
  else
    ok = true

    1.upto(2 * n - 2) do |i|
      y = a[i - 1]
      x = a[i]
      z = a[i + 1]

      next if y == x - 1 || y == (x % n) + 1
      next if z == x - 1 || z == (x % n) + 1

      ok = false
    end

    if ok
      puts 'Yes'
    else
      puts 'No'
    end
  end
end
0