結果
問題 |
No.233 めぐるはめぐる (3)
|
ユーザー |
![]() |
提出日時 | 2016-03-02 15:19:12 |
言語 | Scala(Beta) (3.6.2) |
結果 |
TLE
|
実行時間 | - |
コード長 | 940 bytes |
コンパイル時間 | 7,758 ms |
コンパイル使用メモリ | 261,700 KB |
実行使用メモリ | 89,928 KB |
最終ジャッジ日時 | 2024-06-29 13:10:58 |
合計ジャッジ時間 | 21,633 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | TLE * 11 |
ソースコード
import scala.collection.mutable.{Set=>MSet} object Main { val Consonants = "nbmgr" val Vowels = "iaaeuu" def solve(usedNames: MSet[String]):String = { for (conps <- Consonants.permutations; vowps <- Vowels.permutations) { val cons = conps.toString val vows = vowps.toString val vowslast = vows.last.toString var tenchars = "" for ((c, v) <- cons zip vows) { tenchars += c tenchars += v } for (i <- 0 to 10) { val candidate = tenchars.patch(i, vowslast, 0) if (!usedNames(candidate)) { return candidate } } } return "NO" } def main(args: Array[String]): Unit = { val scanner = new java.util.Scanner(System.in) val n = scanner.nextInt() var usedNames = MSet() : MSet[String] for (_ <- 0 until n) { usedNames(scanner.next()) = true } val answer = solve(usedNames) println(answer) } }