結果

問題 No.233 めぐるはめぐる (3)
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-03-02 15:19:12
言語 Scala(Beta)
(3.4.0)
結果
TLE  
実行時間 -
コード長 940 bytes
コンパイル時間 10,260 ms
コンパイル使用メモリ 259,976 KB
実行使用メモリ 90,116 KB
最終ジャッジ日時 2023-09-11 23:52:44
合計ジャッジ時間 23,130 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 TLE -
testcase_03 TLE -
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
  }
}
0