結果

問題 No.1707 Simple Range Reverse Problem
コンテスト
ユーザー kou_kkk
提出日時 2023-09-03 02:32:04
言語 Nim
(2.2.6)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 497 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,848 ms
コンパイル使用メモリ 73,400 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-05 13:21:14
合計ジャッジ時間 5,330 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9 RE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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