結果

問題 No.233 めぐるはめぐる (3)
ユーザー むらためむらため
提出日時 2019-01-26 20:45:19
言語 Nim
(2.0.2)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 841 bytes
コンパイル時間 3,177 ms
コンパイル使用メモリ 67,944 KB
実行使用メモリ 20,952 KB
最終ジャッジ日時 2023-09-14 03:02:32
合計ジャッジ時間 10,207 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 603 ms
20,540 KB
testcase_08 AC 593 ms
20,620 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(11, 12) Warning: Deprecated since v0.20, use 'initHashSet'; initSet is deprecated [Deprecated]
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]

ソースコード

diff #

import sequtils,algorithm,sets,strutils
template times*(n:int,body) = (for _ in 0..<n: body)
proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  while true:
    let k = getchar_unlocked()
    if k < '0': break
    result = 10 * result + k.ord - '0'.ord

let n = scan()
var used = initSet[string]()
block:
  var cache = "inabameguru"
  n.times:
    for i in 0..<cache.len: cache[i] = getchar_unlocked()
    used.incl cache
    discard getchar_unlocked()
var S = "inabameguru".sorted(cmp).join("")
while true:
  var ok = true
  const consonant = ['n','b','m','g','r']
  if S[^1] in consonant : ok = false
  for i in 1..<S.len:
    if S[i] in consonant and S[i-1] in consonant:
      ok = false
      break
  if ok and S notin used:
    quit S, 0
  if not S.nextPermutation(): break
echo "NO"
0