結果

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

テストケース

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

ソースコード

diff #

T = gets.to_i

T.times do
  n = gets.to_i
  a = gets.split.map(&:to_i)

  if a[0] != 1 || a[-1] != n
    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