結果

問題 No.1707 Simple Range Reverse Problem
ユーザー kou_kkk
提出日時 2023-09-03 02:32:04
言語 Nim
(2.2.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 497 bytes
コンパイル時間 5,711 ms
コンパイル使用メモリ 70,272 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-12 07:19:42
合計ジャッジ時間 5,907 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8 RE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils, strutils, tables

let t = parseInt readLine stdin

proc fn(): bool =
  let
    n = parseInt readLine stdin
    a = stdin.readLine.split.map parseInt
    cntT = a.toCountTable
  if a[0] != 1: return false
  if a[^1] != n: return false
  if cntT.largest.val != 2: return false
  if cntT.smallest.val != 2: return false
  for i in 1 .. a.high:
    let x = abs a[i] - a[pred i]
    if x notin {1, pred n}: return false
  return true

for _ in 0 ..< t:
  echo if fn(): "Yes" else: "No"
0