結果

問題 No.397 NO MORE KADOMATSU
コンテスト
ユーザー むらため
提出日時 2019-01-19 15:16:23
言語 Nim
(2.2.8)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 602 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,411 ms
コンパイル使用メモリ 68,484 KB
実行使用メモリ 28,732 KB
平均クエリ数 125.44
最終ジャッジ日時 2026-03-31 16:30:43
合計ジャッジ時間 3,753 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 54) Warning: imported and not used: 'strformat' [UnusedImport]
/home/judge/data/code/Main.nim(1, 17) Warning: imported and not used: 'strutils' [UnusedImport]
/home/judge/data/code/Main.nim(1, 47) Warning: imported and not used: 'macros' [UnusedImport]
/home/judge/data/code/Main.nim(1, 41) Warning: imported and not used: 'sugar' [UnusedImport]

ソースコード

diff #
raw source code

import sequtils,strutils,algorithm,math,sugar,macros,strformat
proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  while true:
    var k = getchar_unlocked()
    if k < '0': break
    result = 10 * result + k.ord - '0'.ord
let n = scan()
let A = newSeqWith(n,scan())
let B = A.sorted(cmp)
var C = A
var results = newSeq[(int,int)]()
for i in 0..<n:
  if C[i] == B[i]: continue
  for j in i+1..<n:
    if C[j] != B[i]: continue
    swap(C[i],C[j])
    results &= (i,j)
echo results.len()
for rs in results: echo rs[0]," ",rs[1]
discard stdin.readLine()
0