結果
| 問題 | 
                            No.233 めぐるはめぐる (3)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-01-26 20:05:42 | 
| 言語 | Nim  (2.2.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                            (最新)
                                AC
                                 
                             
                            (最初)
                            
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 847 bytes | 
| コンパイル時間 | 3,444 ms | 
| コンパイル使用メモリ | 68,020 KB | 
| 実行使用メモリ | 19,256 KB | 
| 最終ジャッジ日時 | 2024-07-01 10:59:22 | 
| 合計ジャッジ時間 | 10,187 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 3 | 
| other | AC * 2 WA * 9 | 
コンパイルメッセージ
/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]
ソースコード
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']
  for i in 1..<S.len:
    if S[i] in consonant and S[i-1] in consonant:
      ok = false
      break
  if ok and S[^1] in consonant : ok = false
  if ok and S notin used:
    quit S, 0
  if not S.nextPermutation(): break
echo "NO"