scala 사용중인데 RTE(nonzero return code)오류 납니다.

  • fodrh
    fodrh

    object Main extends App {
    def makeTeam(numList: List[Int], acc: List[List[(Int, Int)]], check: Array[Int]): List[List[(Int, Int)]] = {
    if (numList.isEmpty) acc
    else
    (for {
    num1 <- numList
    num2 <- numList if (num1 < num2) && isFriend((num1, num2), check)
    } yield makeTeam(numList filter (elem => elem != num1 && elem != num2), acc.map((num1, num2) :: _), check)).flatten
    }

    def isFriend(pair: (Int, Int), check: Array[Int]): Boolean = {
    def listToTuple(list: List[Int]): List[(Int, Int)] = list match {
    case x :: xs => (x, xs.head) :: listToTuple(xs.tail)
    case Nil => Nil
    }
    val checkList = listToTuple(check.toList)
    checkList.exists { case (x, y) => ((x == pair._1 && y == pair._2) || (x == pair._2 && y == pair._1)) }
    }
    def factorial(n: Int): Int =
    if (n == 0) 1
    else n * factorial(n - 1)

    override def main(args: Array[String]): Unit = {
    val testCase = readInt()
    val saveList: List[(String, String)] = for (count <- (0 until testCase).toList) yield (readLine(), readLine())
    val values: List[Int] = saveList.map {
    case (students, pair) =>
    val numOfStudent: Array[Int] = students.split(" ").map(_.toInt)
    val factori = factorial(numOfStudent(0) / 2)
    val checkPair: Array[Int] = pair.split(" ").map(_.toInt)
    makeTeam((0 until numOfStudent(0)).toList, List(Nil), checkPair).length / factori
    }
    values.map(println)

    }
    }

    코드는 대략 이렇고..
    입력 받는 부분인
    val testCase = readInt()
    val saveList: List[(String, String)] = for (count <- (0 until testCase).toList) yield (readLine(), readLine())
    val values: List[Int] = saveList.map {

    이부분에서 잘못된거 같은데 어디가 잘못됐는지 잘 모르겠습니다.
    로컬에서는 잘 되고 잇거든요ㅜㅜ

    9년 전
2개의 댓글이 있습니다.
  • Being
    Being

    다른 분들의 질문글과 글 작성시 아래 나오는 도움말을 참조하시어 문법 강조가 될 수 있도록 코드를 ~~~ 으로 감싸주시기를 부탁드립니다.


    9년 전 link
  • Being
    Being

    아울러 질문과 답변 게시판에 글 작성시 나오는 "질문하시기 전에" 글을 읽어 주시기 바랍니다. 어떤 문제인지도 적어 두지 않은 채 코드만 덜렁 올려 두시면 누가 답변을 드릴 수 있을까요?


    9년 전 link
  • 정회원 권한이 있어야 커멘트를 다실 수 있습니다. 정회원이 되시려면 온라인 저지에서 5문제 이상을 푸시고, 가입 후 7일 이상이 지나셔야 합니다. 현재 문제를 푸셨습니다.