結果

問題 No.1707 Simple Range Reverse Problem
ユーザー kou_kkk
提出日時 2024-11-27 13:08:24
言語 Nim
(2.2.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 4,664 ms
コンパイル使用メモリ 70,728 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-07-13 03:54:34
合計ジャッジ時間 5,145 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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